Update auto-generated bindings
[ldk-java] / ts / bindings.c
1 #include <rust_types.h>
2 #include "js-wasm.h"
3 #include <stdatomic.h>
4 #include <lightning.h>
5
6 // These should be provided...somehow...
7 void *memset(void *s, int c, size_t n);
8 void *memcpy(void *dest, const void *src, size_t n);
9 int memcmp(const void *s1, const void *s2, size_t n);
10
11 void __attribute__((noreturn)) abort(void);
12 static inline void assert(bool expression) {
13         if (!expression) { abort(); }
14 }
15
16 void *malloc(size_t size);
17 void free(void *ptr);
18
19 #define MALLOC(a, _) malloc(a)
20 #define FREE(p) if ((long)(p) > 1024) { free(p); }
21 #define DO_ASSERT(a) (void)(a)
22 #define CHECK(a)
23
24 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
25 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
27 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
28
29 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
30
31 typedef uint32_t int64_tArray;
32 typedef uint32_t int8_tArray;
33 typedef uint32_t uint32_tArray;
34 typedef uint32_t ptrArray;
35 typedef uint32_t jstring;
36
37 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
38         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
39         elems[0] = arr_len;
40         return (uint32_t)elems;
41 }
42
43 jstring str_ref_to_ts(const char* chars, size_t len) {
44         char* err_buf = MALLOC(len + 4, "str conv buf");
45         *((uint32_t*)err_buf) = len;
46         memcpy(err_buf + 4, chars, len);
47         return (uint32_t) err_buf;
48 }
49
50 typedef bool jboolean;
51
52 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
53         return (uint32_t)MALLOC(size, "JS-Called malloc");
54 }
55 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
56         FREE((void*)ptr);
57 }
58 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
59 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
60         switch (ord) {
61                 case 0: return LDKAccessError_UnknownChain;
62                 case 1: return LDKAccessError_UnknownTx;
63         }
64         abort();
65 }
66 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
67         switch (val) {
68                 case LDKAccessError_UnknownChain: return 0;
69                 case LDKAccessError_UnknownTx: return 1;
70                 default: abort();
71         }
72 }
73 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
74         switch (ord) {
75                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
76                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
77         }
78         abort();
79 }
80 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
81         switch (val) {
82                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
83                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
84                 default: abort();
85         }
86 }
87 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
88         switch (ord) {
89                 case 0: return LDKConfirmationTarget_Background;
90                 case 1: return LDKConfirmationTarget_Normal;
91                 case 2: return LDKConfirmationTarget_HighPriority;
92         }
93         abort();
94 }
95 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
96         switch (val) {
97                 case LDKConfirmationTarget_Background: return 0;
98                 case LDKConfirmationTarget_Normal: return 1;
99                 case LDKConfirmationTarget_HighPriority: return 2;
100                 default: abort();
101         }
102 }
103 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
104         switch (ord) {
105                 case 0: return LDKLevel_Off;
106                 case 1: return LDKLevel_Error;
107                 case 2: return LDKLevel_Warn;
108                 case 3: return LDKLevel_Info;
109                 case 4: return LDKLevel_Debug;
110                 case 5: return LDKLevel_Trace;
111         }
112         abort();
113 }
114 static inline int32_t LDKLevel_to_js(LDKLevel val) {
115         switch (val) {
116                 case LDKLevel_Off: return 0;
117                 case LDKLevel_Error: return 1;
118                 case LDKLevel_Warn: return 2;
119                 case LDKLevel_Info: return 3;
120                 case LDKLevel_Debug: return 4;
121                 case LDKLevel_Trace: return 5;
122                 default: abort();
123         }
124 }
125 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKNetwork_Bitcoin;
128                 case 1: return LDKNetwork_Testnet;
129                 case 2: return LDKNetwork_Regtest;
130                 case 3: return LDKNetwork_Signet;
131         }
132         abort();
133 }
134 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
135         switch (val) {
136                 case LDKNetwork_Bitcoin: return 0;
137                 case LDKNetwork_Testnet: return 1;
138                 case LDKNetwork_Regtest: return 2;
139                 case LDKNetwork_Signet: return 3;
140                 default: abort();
141         }
142 }
143 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
144         switch (ord) {
145                 case 0: return LDKSecp256k1Error_IncorrectSignature;
146                 case 1: return LDKSecp256k1Error_InvalidMessage;
147                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
148                 case 3: return LDKSecp256k1Error_InvalidSignature;
149                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
150                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
151                 case 6: return LDKSecp256k1Error_InvalidTweak;
152                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
153                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
154         }
155         abort();
156 }
157 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
158         switch (val) {
159                 case LDKSecp256k1Error_IncorrectSignature: return 0;
160                 case LDKSecp256k1Error_InvalidMessage: return 1;
161                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
162                 case LDKSecp256k1Error_InvalidSignature: return 3;
163                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
164                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
165                 case LDKSecp256k1Error_InvalidTweak: return 6;
166                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
167                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
168                 default: abort();
169         }
170 }
171 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
172         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
173         ret->datalen = *((uint32_t*)elems);
174         if (ret->datalen == 0) {
175                 ret->data = NULL;
176         } else {
177                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
178                 int8_t *java_elems = (int8_t*)(elems + 4);
179                 for (size_t i = 0; i < ret->datalen; i++) {
180                         ret->data[i] = java_elems[i];
181                 }
182         }
183         return (long)ret;
184 }
185 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
186         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
187         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
188         return ret;
189 }
190 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
191         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
192 }
193 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
194         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
195         CHECK(val->result_ok);
196         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
197         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
198         return res_arr;
199 }
200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
201         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
202         CHECK(!val->result_ok);
203         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
204         return err_conv;
205 }
206 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
207         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
208 }
209 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
210         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
211         CHECK(val->result_ok);
212         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
213         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
214         return res_arr;
215 }
216 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
217         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
218         CHECK(!val->result_ok);
219         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
220         return err_conv;
221 }
222 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
223         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
224 }
225 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
226         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
227         CHECK(val->result_ok);
228         LDKTxCreationKeys res_var = (*val->contents.result);
229         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
230         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
231         long res_ref = (long)res_var.inner & ~1;
232         return res_ref;
233 }
234 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
235         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
236         CHECK(!val->result_ok);
237         LDKDecodeError err_var = (*val->contents.err);
238         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
239         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
240         long err_ref = (long)err_var.inner & ~1;
241         return err_ref;
242 }
243 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
244         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
245 }
246 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
247         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
248         CHECK(val->result_ok);
249         LDKChannelPublicKeys res_var = (*val->contents.result);
250         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
251         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
252         long res_ref = (long)res_var.inner & ~1;
253         return res_ref;
254 }
255 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
256         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
257         CHECK(!val->result_ok);
258         LDKDecodeError err_var = (*val->contents.err);
259         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
260         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
261         long err_ref = (long)err_var.inner & ~1;
262         return err_ref;
263 }
264 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
265         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
266 }
267 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
268         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
269         CHECK(val->result_ok);
270         LDKTxCreationKeys res_var = (*val->contents.result);
271         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
272         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
273         long res_ref = (long)res_var.inner & ~1;
274         return res_ref;
275 }
276 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
277         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
278         CHECK(!val->result_ok);
279         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
280         return err_conv;
281 }
282 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
283         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
284         switch(obj->tag) {
285                 case LDKCOption_u32Z_Some: {
286                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
287                 }
288                 case LDKCOption_u32Z_None: {
289                         return 0 /* LDKCOption_u32Z - None */;
290                 }
291                 default: abort();
292         }
293 }
294 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
295         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
296 }
297 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
298         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
299         CHECK(val->result_ok);
300         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
301         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
302         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
303         long res_ref = (long)res_var.inner & ~1;
304         return res_ref;
305 }
306 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
307         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
308         CHECK(!val->result_ok);
309         LDKDecodeError err_var = (*val->contents.err);
310         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
311         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
312         long err_ref = (long)err_var.inner & ~1;
313         return err_ref;
314 }
315 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
316         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
317 }
318 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
319         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
320         CHECK(val->result_ok);
321         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
322         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
323         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
324         long res_ref = (long)res_var.inner & ~1;
325         return res_ref;
326 }
327 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
328         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
329         CHECK(!val->result_ok);
330         LDKDecodeError err_var = (*val->contents.err);
331         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
332         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
333         long err_ref = (long)err_var.inner & ~1;
334         return err_ref;
335 }
336 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
337         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
338 }
339 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
340         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
341         CHECK(val->result_ok);
342         LDKChannelTransactionParameters res_var = (*val->contents.result);
343         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
344         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
345         long res_ref = (long)res_var.inner & ~1;
346         return res_ref;
347 }
348 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
349         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
350         CHECK(!val->result_ok);
351         LDKDecodeError err_var = (*val->contents.err);
352         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
353         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
354         long err_ref = (long)err_var.inner & ~1;
355         return err_ref;
356 }
357 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
358         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
359 }
360 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
361         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
362         CHECK(val->result_ok);
363         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
364         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
365         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
366         long res_ref = (long)res_var.inner & ~1;
367         return res_ref;
368 }
369 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
370         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
371         CHECK(!val->result_ok);
372         LDKDecodeError err_var = (*val->contents.err);
373         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
374         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
375         long err_ref = (long)err_var.inner & ~1;
376         return err_ref;
377 }
378 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
379         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
380 }
381 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
382         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
383         CHECK(val->result_ok);
384         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
385         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
386         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
387         long res_ref = (long)res_var.inner & ~1;
388         return res_ref;
389 }
390 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
391         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
392         CHECK(!val->result_ok);
393         LDKDecodeError err_var = (*val->contents.err);
394         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396         long err_ref = (long)err_var.inner & ~1;
397         return err_ref;
398 }
399 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
400         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
401 }
402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
403         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
404         CHECK(val->result_ok);
405         LDKCommitmentTransaction res_var = (*val->contents.result);
406         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
407         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
408         long res_ref = (long)res_var.inner & ~1;
409         return res_ref;
410 }
411 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
412         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
413         CHECK(!val->result_ok);
414         LDKDecodeError err_var = (*val->contents.err);
415         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
416         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
417         long err_ref = (long)err_var.inner & ~1;
418         return err_ref;
419 }
420 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
421         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
422 }
423 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
424         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
425         CHECK(val->result_ok);
426         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
427         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
428         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
429         long res_ref = (long)res_var.inner & ~1;
430         return res_ref;
431 }
432 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
433         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
434         CHECK(!val->result_ok);
435         return *val->contents.err;
436 }
437 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
438         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
439 }
440 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
441         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
442         CHECK(val->result_ok);
443         LDKCVec_SignatureZ res_var = (*val->contents.result);
444         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
445         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
446         for (size_t m = 0; m < res_var.datalen; m++) {
447                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
448                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
449                 res_arr_ptr[m] = res_conv_12_arr;
450         }
451         return res_arr;
452 }
453 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
454         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
455         CHECK(!val->result_ok);
456         return *val->contents.err;
457 }
458 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
459         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
460         switch(obj->tag) {
461                 case LDKErrorAction_DisconnectPeer: {
462                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
463                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
464                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
465                         long msg_ref = (long)msg_var.inner & ~1;
466                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
467                 }
468                 case LDKErrorAction_IgnoreError: {
469                         return 0 /* LDKErrorAction - IgnoreError */;
470                 }
471                 case LDKErrorAction_SendErrorMessage: {
472                         LDKErrorMessage msg_var = obj->send_error_message.msg;
473                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
474                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
475                         long msg_ref = (long)msg_var.inner & ~1;
476                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
477                 }
478                 default: abort();
479         }
480 }
481 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
482         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
483         switch(obj->tag) {
484                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
485                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
486                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
487                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
488                         long msg_ref = (long)msg_var.inner & ~1;
489                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
490                 }
491                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
492                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
493                 }
494                 case LDKHTLCFailChannelUpdate_NodeFailure: {
495                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
496                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
497                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
498                 }
499                 default: abort();
500         }
501 }
502 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
503         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
504         switch(obj->tag) {
505                 case LDKMessageSendEvent_SendAcceptChannel: {
506                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
507                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
508                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
509                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
510                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
511                         long msg_ref = (long)msg_var.inner & ~1;
512                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
513                 }
514                 case LDKMessageSendEvent_SendOpenChannel: {
515                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
516                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
517                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
518                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
519                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
520                         long msg_ref = (long)msg_var.inner & ~1;
521                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
522                 }
523                 case LDKMessageSendEvent_SendFundingCreated: {
524                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
525                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
526                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
527                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
528                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
529                         long msg_ref = (long)msg_var.inner & ~1;
530                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
531                 }
532                 case LDKMessageSendEvent_SendFundingSigned: {
533                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
534                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
535                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
536                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
537                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
538                         long msg_ref = (long)msg_var.inner & ~1;
539                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
540                 }
541                 case LDKMessageSendEvent_SendFundingLocked: {
542                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
543                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
544                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
545                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
546                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
547                         long msg_ref = (long)msg_var.inner & ~1;
548                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
549                 }
550                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
551                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
552                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
553                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
554                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
555                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
556                         long msg_ref = (long)msg_var.inner & ~1;
557                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
558                 }
559                 case LDKMessageSendEvent_UpdateHTLCs: {
560                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
561                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
562                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
563                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
564                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
565                         long updates_ref = (long)updates_var.inner & ~1;
566                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
567                 }
568                 case LDKMessageSendEvent_SendRevokeAndACK: {
569                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
570                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
571                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
572                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
573                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
574                         long msg_ref = (long)msg_var.inner & ~1;
575                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
576                 }
577                 case LDKMessageSendEvent_SendClosingSigned: {
578                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
579                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
580                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
581                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
582                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
583                         long msg_ref = (long)msg_var.inner & ~1;
584                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
585                 }
586                 case LDKMessageSendEvent_SendShutdown: {
587                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
588                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
589                         LDKShutdown msg_var = obj->send_shutdown.msg;
590                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
591                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
592                         long msg_ref = (long)msg_var.inner & ~1;
593                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
594                 }
595                 case LDKMessageSendEvent_SendChannelReestablish: {
596                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
597                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
598                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
599                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
600                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
601                         long msg_ref = (long)msg_var.inner & ~1;
602                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
603                 }
604                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
605                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
606                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
607                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
608                         long msg_ref = (long)msg_var.inner & ~1;
609                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
610                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
611                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
612                         long update_msg_ref = (long)update_msg_var.inner & ~1;
613                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
614                 }
615                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
616                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
617                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
618                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
619                         long msg_ref = (long)msg_var.inner & ~1;
620                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
621                 }
622                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
623                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
624                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
625                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
626                         long msg_ref = (long)msg_var.inner & ~1;
627                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
628                 }
629                 case LDKMessageSendEvent_HandleError: {
630                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
631                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
632                         long action_ref = ((long)&obj->handle_error.action) | 1;
633                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
634                 }
635                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
636                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
637                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
638                 }
639                 case LDKMessageSendEvent_SendChannelRangeQuery: {
640                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
641                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
642                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
643                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
644                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
645                         long msg_ref = (long)msg_var.inner & ~1;
646                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
647                 }
648                 case LDKMessageSendEvent_SendShortIdsQuery: {
649                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
650                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
651                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
652                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
653                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
654                         long msg_ref = (long)msg_var.inner & ~1;
655                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
656                 }
657                 case LDKMessageSendEvent_SendReplyChannelRange: {
658                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
659                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
660                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
661                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
662                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
663                         long msg_ref = (long)msg_var.inner & ~1;
664                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
665                 }
666                 default: abort();
667         }
668 }
669 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
670         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
671         ret->datalen = *((uint32_t*)elems);
672         if (ret->datalen == 0) {
673                 ret->data = NULL;
674         } else {
675                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
676                 uint32_t *java_elems = (uint32_t*)(elems + 4);
677                 for (size_t i = 0; i < ret->datalen; i++) {
678                         uint32_t arr_elem = java_elems[i];
679                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
680                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
681                         ret->data[i] = arr_elem_conv;
682                 }
683         }
684         return (long)ret;
685 }
686 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
687         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
688         for (size_t i = 0; i < ret.datalen; i++) {
689                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
690         }
691         return ret;
692 }
693 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
694         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
695 }
696 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
697         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
698         CHECK(val->result_ok);
699         return *val->contents.result;
700 }
701 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
702         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
703         CHECK(!val->result_ok);
704         LDKLightningError err_var = (*val->contents.err);
705         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
706         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
707         long err_ref = (long)err_var.inner & ~1;
708         return err_ref;
709 }
710 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
711         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
712         LDKChannelAnnouncement a_conv;
713         a_conv.inner = (void*)(a & (~1));
714         a_conv.is_owned = (a & 1) || (a == 0);
715         a_conv = ChannelAnnouncement_clone(&a_conv);
716         ret->a = a_conv;
717         LDKChannelUpdate b_conv;
718         b_conv.inner = (void*)(b & (~1));
719         b_conv.is_owned = (b & 1) || (b == 0);
720         b_conv = ChannelUpdate_clone(&b_conv);
721         ret->b = b_conv;
722         LDKChannelUpdate c_conv;
723         c_conv.inner = (void*)(c & (~1));
724         c_conv.is_owned = (c & 1) || (c == 0);
725         c_conv = ChannelUpdate_clone(&c_conv);
726         ret->c = c_conv;
727         return (long)ret;
728 }
729 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
730         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
731         LDKChannelAnnouncement a_var = tuple->a;
732         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
733         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
734         long a_ref = (long)a_var.inner & ~1;
735         return a_ref;
736 }
737 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
738         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
739         LDKChannelUpdate b_var = tuple->b;
740         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
741         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
742         long b_ref = (long)b_var.inner & ~1;
743         return b_ref;
744 }
745 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
746         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
747         LDKChannelUpdate c_var = tuple->c;
748         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
749         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
750         long c_ref = (long)c_var.inner & ~1;
751         return c_ref;
752 }
753 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
754         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
755         ret->datalen = *((uint32_t*)elems);
756         if (ret->datalen == 0) {
757                 ret->data = NULL;
758         } else {
759                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
760                 uint32_t *java_elems = (uint32_t*)(elems + 4);
761                 for (size_t i = 0; i < ret->datalen; i++) {
762                         uint32_t arr_elem = java_elems[i];
763                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
764                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
765                         ret->data[i] = arr_elem_conv;
766                 }
767         }
768         return (long)ret;
769 }
770 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
771         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
772         for (size_t i = 0; i < ret.datalen; i++) {
773                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
774         }
775         return ret;
776 }
777 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
778         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
779         ret->datalen = *((uint32_t*)elems);
780         if (ret->datalen == 0) {
781                 ret->data = NULL;
782         } else {
783                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
784                 uint32_t *java_elems = (uint32_t*)(elems + 4);
785                 for (size_t i = 0; i < ret->datalen; i++) {
786                         uint32_t arr_elem = java_elems[i];
787                         LDKNodeAnnouncement arr_elem_conv;
788                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
789                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
790                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
791                         ret->data[i] = arr_elem_conv;
792                 }
793         }
794         return (long)ret;
795 }
796 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
797         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
798         for (size_t i = 0; i < ret.datalen; i++) {
799                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
800         }
801         return ret;
802 }
803 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
804         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
805 }
806 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
807         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
808         CHECK(val->result_ok);
809         return *val->contents.result;
810 }
811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
812         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
813         CHECK(!val->result_ok);
814         LDKLightningError err_var = (*val->contents.err);
815         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
816         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
817         long err_ref = (long)err_var.inner & ~1;
818         return err_ref;
819 }
820 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
821         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
822 }
823 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
824         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
825         CHECK(val->result_ok);
826         LDKCVec_u8Z res_var = (*val->contents.result);
827         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
828         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
829         return res_arr;
830 }
831 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
832         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
833         CHECK(!val->result_ok);
834         LDKPeerHandleError err_var = (*val->contents.err);
835         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
836         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
837         long err_ref = (long)err_var.inner & ~1;
838         return err_ref;
839 }
840 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
841         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
842 }
843 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
844         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
845         CHECK(val->result_ok);
846         return *val->contents.result;
847 }
848 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
849         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
850         CHECK(!val->result_ok);
851         LDKPeerHandleError err_var = (*val->contents.err);
852         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
853         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
854         long err_ref = (long)err_var.inner & ~1;
855         return err_ref;
856 }
857 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
858         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
859 }
860 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
861         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
862         CHECK(val->result_ok);
863         return *val->contents.result;
864 }
865 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
866         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
867         CHECK(!val->result_ok);
868         LDKPeerHandleError err_var = (*val->contents.err);
869         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
870         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
871         long err_ref = (long)err_var.inner & ~1;
872         return err_ref;
873 }
874 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
875         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
876 }
877 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
878         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
879         CHECK(val->result_ok);
880         LDKInitFeatures res_var = (*val->contents.result);
881         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
882         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
883         long res_ref = (long)res_var.inner & ~1;
884         return res_ref;
885 }
886 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
887         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
888         CHECK(!val->result_ok);
889         LDKDecodeError err_var = (*val->contents.err);
890         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
891         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
892         long err_ref = (long)err_var.inner & ~1;
893         return err_ref;
894 }
895 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
896         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
897 }
898 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
899         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
900         CHECK(val->result_ok);
901         LDKNodeFeatures res_var = (*val->contents.result);
902         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
903         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
904         long res_ref = (long)res_var.inner & ~1;
905         return res_ref;
906 }
907 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
908         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
909         CHECK(!val->result_ok);
910         LDKDecodeError err_var = (*val->contents.err);
911         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         long err_ref = (long)err_var.inner & ~1;
914         return err_ref;
915 }
916 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
917         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
918 }
919 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
920         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
921         CHECK(val->result_ok);
922         LDKChannelFeatures res_var = (*val->contents.result);
923         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925         long res_ref = (long)res_var.inner & ~1;
926         return res_ref;
927 }
928 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
929         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
930         CHECK(!val->result_ok);
931         LDKDecodeError err_var = (*val->contents.err);
932         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934         long err_ref = (long)err_var.inner & ~1;
935         return err_ref;
936 }
937 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
938         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
939 }
940 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
941         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
942         CHECK(val->result_ok);
943         LDKInvoiceFeatures res_var = (*val->contents.result);
944         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
945         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
946         long res_ref = (long)res_var.inner & ~1;
947         return res_ref;
948 }
949 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
950         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
951         CHECK(!val->result_ok);
952         LDKDecodeError err_var = (*val->contents.err);
953         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955         long err_ref = (long)err_var.inner & ~1;
956         return err_ref;
957 }
958 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
959         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
960 }
961 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
962         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
963         CHECK(val->result_ok);
964         LDKChannelConfig res_var = (*val->contents.result);
965         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
966         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
967         long res_ref = (long)res_var.inner & ~1;
968         return res_ref;
969 }
970 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
971         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
972         CHECK(!val->result_ok);
973         LDKDecodeError err_var = (*val->contents.err);
974         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
975         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
976         long err_ref = (long)err_var.inner & ~1;
977         return err_ref;
978 }
979 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
980         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
981         switch(obj->tag) {
982                 case LDKCOption_u64Z_Some: {
983                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
984                 }
985                 case LDKCOption_u64Z_None: {
986                         return 0 /* LDKCOption_u64Z - None */;
987                 }
988                 default: abort();
989         }
990 }
991 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
992         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
993 }
994 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
995         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
996         CHECK(val->result_ok);
997         LDKDirectionalChannelInfo res_var = (*val->contents.result);
998         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
999         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1000         long res_ref = (long)res_var.inner & ~1;
1001         return res_ref;
1002 }
1003 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
1004         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
1005         CHECK(!val->result_ok);
1006         LDKDecodeError err_var = (*val->contents.err);
1007         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1008         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1009         long err_ref = (long)err_var.inner & ~1;
1010         return err_ref;
1011 }
1012 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
1013         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
1014 }
1015 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
1016         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1017         CHECK(val->result_ok);
1018         LDKChannelInfo res_var = (*val->contents.result);
1019         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1020         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1021         long res_ref = (long)res_var.inner & ~1;
1022         return res_ref;
1023 }
1024 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
1025         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
1026         CHECK(!val->result_ok);
1027         LDKDecodeError err_var = (*val->contents.err);
1028         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1029         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1030         long err_ref = (long)err_var.inner & ~1;
1031         return err_ref;
1032 }
1033 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
1034         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1035 }
1036 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
1037         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1038         CHECK(val->result_ok);
1039         LDKRoutingFees res_var = (*val->contents.result);
1040         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1041         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1042         long res_ref = (long)res_var.inner & ~1;
1043         return res_ref;
1044 }
1045 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
1046         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1047         CHECK(!val->result_ok);
1048         LDKDecodeError err_var = (*val->contents.err);
1049         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1050         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1051         long err_ref = (long)err_var.inner & ~1;
1052         return err_ref;
1053 }
1054 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1055         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
1056         switch(obj->tag) {
1057                 case LDKNetAddress_IPv4: {
1058                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1059                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1060                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1061                 }
1062                 case LDKNetAddress_IPv6: {
1063                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1064                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1065                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1066                 }
1067                 case LDKNetAddress_OnionV2: {
1068                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1069                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1070                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1071                 }
1072                 case LDKNetAddress_OnionV3: {
1073                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1074                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1075                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1076                 }
1077                 default: abort();
1078         }
1079 }
1080 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1081         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1082         ret->datalen = *((uint32_t*)elems);
1083         if (ret->datalen == 0) {
1084                 ret->data = NULL;
1085         } else {
1086                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1087                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1088                 for (size_t i = 0; i < ret->datalen; i++) {
1089                         uint32_t arr_elem = java_elems[i];
1090                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1091                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
1092                         ret->data[i] = arr_elem_conv;
1093                 }
1094         }
1095         return (long)ret;
1096 }
1097 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1098         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1099         for (size_t i = 0; i < ret.datalen; i++) {
1100                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1101         }
1102         return ret;
1103 }
1104 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
1105         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1106 }
1107 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
1108         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1109         CHECK(val->result_ok);
1110         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1111         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1112         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1113         long res_ref = (long)res_var.inner & ~1;
1114         return res_ref;
1115 }
1116 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
1117         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1118         CHECK(!val->result_ok);
1119         LDKDecodeError err_var = (*val->contents.err);
1120         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1121         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1122         long err_ref = (long)err_var.inner & ~1;
1123         return err_ref;
1124 }
1125 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
1126         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1127         ret->datalen = *((uint32_t*)elems);
1128         if (ret->datalen == 0) {
1129                 ret->data = NULL;
1130         } else {
1131                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1132                 int64_t *java_elems = (int64_t*)(elems + 4);
1133                 for (size_t i = 0; i < ret->datalen; i++) {
1134                         ret->data[i] = java_elems[i];
1135                 }
1136         }
1137         return (long)ret;
1138 }
1139 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1140         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1141         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1142         return ret;
1143 }
1144 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
1145         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1146 }
1147 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
1148         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1149         CHECK(val->result_ok);
1150         LDKNodeInfo res_var = (*val->contents.result);
1151         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1152         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1153         long res_ref = (long)res_var.inner & ~1;
1154         return res_ref;
1155 }
1156 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
1157         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1158         CHECK(!val->result_ok);
1159         LDKDecodeError err_var = (*val->contents.err);
1160         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1161         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1162         long err_ref = (long)err_var.inner & ~1;
1163         return err_ref;
1164 }
1165 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
1166         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1167 }
1168 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
1169         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1170         CHECK(val->result_ok);
1171         LDKNetworkGraph res_var = (*val->contents.result);
1172         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1173         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1174         long res_ref = (long)res_var.inner & ~1;
1175         return res_ref;
1176 }
1177 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
1178         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1179         CHECK(!val->result_ok);
1180         LDKDecodeError err_var = (*val->contents.err);
1181         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1182         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1183         long err_ref = (long)err_var.inner & ~1;
1184         return err_ref;
1185 }
1186 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
1187         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1188         ret->a = a;
1189         LDKTransaction b_ref;
1190         b_ref.datalen = *((uint32_t*)b);
1191         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1192         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1193         b_ref.data_is_owned = false;
1194         ret->b = b_ref;
1195         return (long)ret;
1196 }
1197 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
1198         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1199         return tuple->a;
1200 }
1201 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
1202         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1203         LDKTransaction b_var = tuple->b;
1204         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1205         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1206         return b_arr;
1207 }
1208 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
1209         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1210         ret->datalen = *((uint32_t*)elems);
1211         if (ret->datalen == 0) {
1212                 ret->data = NULL;
1213         } else {
1214                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1215                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1216                 for (size_t i = 0; i < ret->datalen; i++) {
1217                         uint32_t arr_elem = java_elems[i];
1218                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1219                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
1220                         ret->data[i] = arr_elem_conv;
1221                 }
1222         }
1223         return (long)ret;
1224 }
1225 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
1226         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1227 }
1228 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
1229         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1230         CHECK(val->result_ok);
1231         return *val->contents.result;
1232 }
1233 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
1234         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1235         CHECK(!val->result_ok);
1236         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
1237         return err_conv;
1238 }
1239 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
1240         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1241         switch(obj->tag) {
1242                 case LDKMonitorEvent_HTLCEvent: {
1243                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1244                         CHECK((((long)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1245                         CHECK((((long)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1246                         long htlc_event_ref = (long)htlc_event_var.inner & ~1;
1247                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
1248                 }
1249                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1250                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1251                         CHECK((((long)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1252                         CHECK((((long)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1253                         long commitment_tx_broadcasted_ref = (long)commitment_tx_broadcasted_var.inner & ~1;
1254                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
1255                 }
1256                 default: abort();
1257         }
1258 }
1259 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
1260         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1261         ret->datalen = *((uint32_t*)elems);
1262         if (ret->datalen == 0) {
1263                 ret->data = NULL;
1264         } else {
1265                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1266                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1267                 for (size_t i = 0; i < ret->datalen; i++) {
1268                         uint32_t arr_elem = java_elems[i];
1269                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1270                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1271                         ret->data[i] = arr_elem_conv;
1272                 }
1273         }
1274         return (long)ret;
1275 }
1276 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1277         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1278         for (size_t i = 0; i < ret.datalen; i++) {
1279                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1280         }
1281         return ret;
1282 }
1283 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1284         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1285         switch(obj->tag) {
1286                 case LDKSpendableOutputDescriptor_StaticOutput: {
1287                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1288                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1289                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1290                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1291                         long output_ref = ((long)&obj->static_output.output) | 1;
1292                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
1293                 }
1294                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1295                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1296                         CHECK((((long)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1297                         CHECK((((long)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1298                         long delayed_payment_output_ref = (long)delayed_payment_output_var.inner & ~1;
1299                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1300                 }
1301                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1302                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1303                         CHECK((((long)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1304                         CHECK((((long)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1305                         long static_payment_output_ref = (long)static_payment_output_var.inner & ~1;
1306                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1307                 }
1308                 default: abort();
1309         }
1310 }
1311 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1312         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1313         ret->datalen = *((uint32_t*)elems);
1314         if (ret->datalen == 0) {
1315                 ret->data = NULL;
1316         } else {
1317                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1318                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1319                 for (size_t i = 0; i < ret->datalen; i++) {
1320                         uint32_t arr_elem = java_elems[i];
1321                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1322                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1323                         ret->data[i] = arr_elem_conv;
1324                 }
1325         }
1326         return (long)ret;
1327 }
1328 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1329         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1330         for (size_t i = 0; i < ret.datalen; i++) {
1331                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1332         }
1333         return ret;
1334 }
1335 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
1336         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1337         switch(obj->tag) {
1338                 case LDKEvent_FundingGenerationReady: {
1339                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1340                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
1341                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1342                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1343                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
1344                         return 0 /* LDKEvent - FundingGenerationReady */; (void) temporary_channel_id_arr; (void) obj->funding_generation_ready.channel_value_satoshis; (void) output_script_arr; (void) obj->funding_generation_ready.user_channel_id;
1345                 }
1346                 case LDKEvent_FundingBroadcastSafe: {
1347                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1348                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1349                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1350                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1351                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
1352                 }
1353                 case LDKEvent_PaymentReceived: {
1354                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1355                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
1356                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1357                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
1358                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
1359                 }
1360                 case LDKEvent_PaymentSent: {
1361                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1362                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
1363                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
1364                 }
1365                 case LDKEvent_PaymentFailed: {
1366                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1367                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
1368                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
1369                 }
1370                 case LDKEvent_PendingHTLCsForwardable: {
1371                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
1372                 }
1373                 case LDKEvent_SpendableOutputs: {
1374                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1375                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1376                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
1377                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1378                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1379                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1380                         }
1381                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
1382                 }
1383                 default: abort();
1384         }
1385 }
1386 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
1387         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1388         ret->datalen = *((uint32_t*)elems);
1389         if (ret->datalen == 0) {
1390                 ret->data = NULL;
1391         } else {
1392                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1393                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1394                 for (size_t i = 0; i < ret->datalen; i++) {
1395                         uint32_t arr_elem = java_elems[i];
1396                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1397                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
1398                         ret->data[i] = arr_elem_conv;
1399                 }
1400         }
1401         return (long)ret;
1402 }
1403 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1404         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1405         for (size_t i = 0; i < ret.datalen; i++) {
1406                 ret.data[i] = Event_clone(&orig->data[i]);
1407         }
1408         return ret;
1409 }
1410 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
1411         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1412 }
1413 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
1414         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1415         CHECK(val->result_ok);
1416         LDKOutPoint res_var = (*val->contents.result);
1417         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1418         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1419         long res_ref = (long)res_var.inner & ~1;
1420         return res_ref;
1421 }
1422 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
1423         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1424         CHECK(!val->result_ok);
1425         LDKDecodeError err_var = (*val->contents.err);
1426         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1427         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1428         long err_ref = (long)err_var.inner & ~1;
1429         return err_ref;
1430 }
1431 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1432         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1433 }
1434 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1435         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1436         CHECK(val->result_ok);
1437         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1438         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1439         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1440         long res_ref = (long)res_var.inner & ~1;
1441         return res_ref;
1442 }
1443 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
1444         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1445         CHECK(!val->result_ok);
1446         LDKDecodeError err_var = (*val->contents.err);
1447         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449         long err_ref = (long)err_var.inner & ~1;
1450         return err_ref;
1451 }
1452 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1453         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
1454 }
1455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1456         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1457         CHECK(val->result_ok);
1458         LDKHTLCUpdate res_var = (*val->contents.result);
1459         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1460         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1461         long res_ref = (long)res_var.inner & ~1;
1462         return res_ref;
1463 }
1464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
1465         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1466         CHECK(!val->result_ok);
1467         LDKDecodeError err_var = (*val->contents.err);
1468         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1469         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1470         long err_ref = (long)err_var.inner & ~1;
1471         return err_ref;
1472 }
1473 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
1474         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
1475 }
1476 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
1477         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1478         CHECK(val->result_ok);
1479         return *val->contents.result;
1480 }
1481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
1482         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1483         CHECK(!val->result_ok);
1484         LDKMonitorUpdateError err_var = (*val->contents.err);
1485         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1486         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1487         long err_ref = (long)err_var.inner & ~1;
1488         return err_ref;
1489 }
1490 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
1491         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
1492         LDKOutPoint a_conv;
1493         a_conv.inner = (void*)(a & (~1));
1494         a_conv.is_owned = (a & 1) || (a == 0);
1495         a_conv = OutPoint_clone(&a_conv);
1496         ret->a = a_conv;
1497         LDKCVec_u8Z b_ref;
1498         b_ref.datalen = *((uint32_t*)b);
1499         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1500         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1501         ret->b = b_ref;
1502         return (long)ret;
1503 }
1504 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
1505         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1506         LDKOutPoint a_var = tuple->a;
1507         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1508         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1509         long a_ref = (long)a_var.inner & ~1;
1510         return a_ref;
1511 }
1512 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
1513         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1514         LDKCVec_u8Z b_var = tuple->b;
1515         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1516         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1517         return b_arr;
1518 }
1519 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
1520         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
1521         ret->a = a;
1522         LDKCVec_u8Z b_ref;
1523         b_ref.datalen = *((uint32_t*)b);
1524         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1525         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1526         ret->b = b_ref;
1527         return (long)ret;
1528 }
1529 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
1530         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1531         return tuple->a;
1532 }
1533 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
1534         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1535         LDKCVec_u8Z b_var = tuple->b;
1536         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1537         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1538         return b_arr;
1539 }
1540 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
1541         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
1542         ret->datalen = *((uint32_t*)elems);
1543         if (ret->datalen == 0) {
1544                 ret->data = NULL;
1545         } else {
1546                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
1547                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1548                 for (size_t i = 0; i < ret->datalen; i++) {
1549                         uint32_t arr_elem = java_elems[i];
1550                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
1551                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
1552                         ret->data[i] = arr_elem_conv;
1553                 }
1554         }
1555         return (long)ret;
1556 }
1557 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
1558         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
1559         for (size_t i = 0; i < ret.datalen; i++) {
1560                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
1561         }
1562         return ret;
1563 }
1564 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
1565         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
1566         LDKThirtyTwoBytes a_ref;
1567         CHECK(*((uint32_t*)a) == 32);
1568         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1569         ret->a = a_ref;
1570         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
1571         b_constr.datalen = *((uint32_t*)b);
1572         if (b_constr.datalen > 0)
1573                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
1574         else
1575                 b_constr.data = NULL;
1576         uint32_t* b_vals = (uint32_t*)(b + 4);
1577         for (size_t e = 0; e < b_constr.datalen; e++) {
1578                 uint32_t b_conv_30 = b_vals[e];
1579                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
1580                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
1581                 b_constr.data[e] = b_conv_30_conv;
1582         }
1583         ret->b = b_constr;
1584         return (long)ret;
1585 }
1586 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
1587         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1588         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1589         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1590         return a_arr;
1591 }
1592 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
1593         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1594         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
1595         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1596         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1597         for (size_t e = 0; e < b_var.datalen; e++) {
1598                 long b_conv_30_ref = (long)(&b_var.data[e]) | 1;
1599                 b_arr_ptr[e] = b_conv_30_ref;
1600         }
1601         return b_arr;
1602 }
1603 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
1604         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
1605         ret->datalen = *((uint32_t*)elems);
1606         if (ret->datalen == 0) {
1607                 ret->data = NULL;
1608         } else {
1609                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
1610                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1611                 for (size_t i = 0; i < ret->datalen; i++) {
1612                         uint32_t arr_elem = java_elems[i];
1613                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
1614                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ
1615                         ret->data[i] = arr_elem_conv;
1616                 }
1617         }
1618         return (long)ret;
1619 }
1620 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
1621         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1622         ret->a = a;
1623         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1624         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
1625         ret->b = b_conv;
1626         return (long)ret;
1627 }
1628 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
1629         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1630         return tuple->a;
1631 }
1632 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
1633         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1634         long b_ref = ((long)&tuple->b) | 1;
1635         return (long)b_ref;
1636 }
1637 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
1638         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1639         ret->datalen = *((uint32_t*)elems);
1640         if (ret->datalen == 0) {
1641                 ret->data = NULL;
1642         } else {
1643                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1644                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1645                 for (size_t i = 0; i < ret->datalen; i++) {
1646                         uint32_t arr_elem = java_elems[i];
1647                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1648                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
1649                         ret->data[i] = arr_elem_conv;
1650                 }
1651         }
1652         return (long)ret;
1653 }
1654 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1655         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1656         for (size_t i = 0; i < ret.datalen; i++) {
1657                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1658         }
1659         return ret;
1660 }
1661 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
1662         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
1663         LDKThirtyTwoBytes a_ref;
1664         CHECK(*((uint32_t*)a) == 32);
1665         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1666         ret->a = a_ref;
1667         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
1668         b_constr.datalen = *((uint32_t*)b);
1669         if (b_constr.datalen > 0)
1670                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
1671         else
1672                 b_constr.data = NULL;
1673         uint32_t* b_vals = (uint32_t*)(b + 4);
1674         for (size_t z = 0; z < b_constr.datalen; z++) {
1675                 uint32_t b_conv_25 = b_vals[z];
1676                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
1677                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
1678                 b_constr.data[z] = b_conv_25_conv;
1679         }
1680         ret->b = b_constr;
1681         return (long)ret;
1682 }
1683 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
1684         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1685         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1686         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1687         return a_arr;
1688 }
1689 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
1690         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1691         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1692         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1693         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1694         for (size_t z = 0; z < b_var.datalen; z++) {
1695                 long b_conv_25_ref = (long)(&b_var.data[z]) | 1;
1696                 b_arr_ptr[z] = b_conv_25_ref;
1697         }
1698         return b_arr;
1699 }
1700 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
1701         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1702         ret->datalen = *((uint32_t*)elems);
1703         if (ret->datalen == 0) {
1704                 ret->data = NULL;
1705         } else {
1706                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1707                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1708                 for (size_t i = 0; i < ret->datalen; i++) {
1709                         uint32_t arr_elem = java_elems[i];
1710                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1711                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1712                         ret->data[i] = arr_elem_conv;
1713                 }
1714         }
1715         return (long)ret;
1716 }
1717 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1718         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1719         LDKSignature a_ref;
1720         CHECK(*((uint32_t*)a) == 64);
1721         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1722         ret->a = a_ref;
1723         LDKCVec_SignatureZ b_constr;
1724         b_constr.datalen = *((uint32_t*)b);
1725         if (b_constr.datalen > 0)
1726                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1727         else
1728                 b_constr.data = NULL;
1729         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1730         for (size_t m = 0; m < b_constr.datalen; m++) {
1731                 int8_tArray b_conv_12 = b_vals[m];
1732                 LDKSignature b_conv_12_ref;
1733                 CHECK(*((uint32_t*)b_conv_12) == 64);
1734                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1735                 b_constr.data[m] = b_conv_12_ref;
1736         }
1737         ret->b = b_constr;
1738         return (long)ret;
1739 }
1740 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1741         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1742         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1743         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1744         return a_arr;
1745 }
1746 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1747         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1748         LDKCVec_SignatureZ b_var = tuple->b;
1749         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1750         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1751         for (size_t m = 0; m < b_var.datalen; m++) {
1752                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1753                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1754                 b_arr_ptr[m] = b_conv_12_arr;
1755         }
1756         return b_arr;
1757 }
1758 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1759         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1760 }
1761 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1762         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1763         CHECK(val->result_ok);
1764         long res_ref = (long)(&(*val->contents.result)) | 1;
1765         return res_ref;
1766 }
1767 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1768         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1769         CHECK(!val->result_ok);
1770         return *val->contents.err;
1771 }
1772 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1773         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1774 }
1775 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1776         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1777         CHECK(val->result_ok);
1778         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1779         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1780         return res_arr;
1781 }
1782 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1783         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1784         CHECK(!val->result_ok);
1785         return *val->contents.err;
1786 }
1787 typedef struct LDKSign_JCalls {
1788         atomic_size_t refcnt;
1789         uint32_t get_per_commitment_point_meth;
1790         uint32_t release_commitment_secret_meth;
1791         uint32_t channel_keys_id_meth;
1792         uint32_t sign_counterparty_commitment_meth;
1793         uint32_t sign_holder_commitment_and_htlcs_meth;
1794         uint32_t sign_justice_transaction_meth;
1795         uint32_t sign_counterparty_htlc_transaction_meth;
1796         uint32_t sign_closing_transaction_meth;
1797         uint32_t sign_channel_announcement_meth;
1798         uint32_t ready_channel_meth;
1799         uint32_t write_meth;
1800 } LDKSign_JCalls;
1801 static void LDKSign_JCalls_free(void* this_arg) {
1802         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1803         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1804                 js_free(j_calls->get_per_commitment_point_meth);
1805                 js_free(j_calls->release_commitment_secret_meth);
1806                 js_free(j_calls->channel_keys_id_meth);
1807                 js_free(j_calls->sign_counterparty_commitment_meth);
1808                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1809                 js_free(j_calls->sign_justice_transaction_meth);
1810                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1811                 js_free(j_calls->sign_closing_transaction_meth);
1812                 js_free(j_calls->sign_channel_announcement_meth);
1813                 js_free(j_calls->ready_channel_meth);
1814                 js_free(j_calls->write_meth);
1815                 FREE(j_calls);
1816         }
1817 }
1818 LDKPublicKey get_per_commitment_point_LDKSign_jcall(const void* this_arg, uint64_t idx) {
1819         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1820         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1821         LDKPublicKey ret_ref;
1822         CHECK(*((uint32_t*)ret) == 33);
1823         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1824         return ret_ref;
1825 }
1826 LDKThirtyTwoBytes release_commitment_secret_LDKSign_jcall(const void* this_arg, uint64_t idx) {
1827         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1828         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1829         LDKThirtyTwoBytes ret_ref;
1830         CHECK(*((uint32_t*)ret) == 32);
1831         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1832         return ret_ref;
1833 }
1834 LDKThirtyTwoBytes channel_keys_id_LDKSign_jcall(const void* this_arg) {
1835         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1836         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1837         LDKThirtyTwoBytes ret_ref;
1838         CHECK(*((uint32_t*)ret) == 32);
1839         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1840         return ret_ref;
1841 }
1842 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1843         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1844         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1845         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1846         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848         long commitment_tx_ref = (long)commitment_tx_var.inner;
1849         if (commitment_tx_var.is_owned) {
1850                 commitment_tx_ref |= 1;
1851         }
1852         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1853         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1854         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1855         return ret_conv;
1856 }
1857 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1858         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1859         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1860         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1861         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1862         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1863         long commitment_tx_ref = (long)commitment_tx_var.inner;
1864         if (commitment_tx_var.is_owned) {
1865                 commitment_tx_ref |= 1;
1866         }
1867         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1868         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1869         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1870         return ret_conv;
1871 }
1872 LDKCResult_SignatureNoneZ sign_justice_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1873         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1874         LDKTransaction justice_tx_var = justice_tx;
1875         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1876         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1877         Transaction_free(justice_tx_var);
1878         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1879         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1880         LDKHTLCOutputInCommitment htlc_var = *htlc;
1881         htlc_var = HTLCOutputInCommitment_clone(htlc);
1882         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1883         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1884         long htlc_ref = (long)htlc_var.inner;
1885         if (htlc_var.is_owned) {
1886                 htlc_ref |= 1;
1887         }
1888         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1889         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1890         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1891         return ret_conv;
1892 }
1893 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1894         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1895         LDKTransaction htlc_tx_var = htlc_tx;
1896         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1897         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1898         Transaction_free(htlc_tx_var);
1899         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1900         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1901         LDKHTLCOutputInCommitment htlc_var = *htlc;
1902         htlc_var = HTLCOutputInCommitment_clone(htlc);
1903         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1904         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1905         long htlc_ref = (long)htlc_var.inner;
1906         if (htlc_var.is_owned) {
1907                 htlc_ref |= 1;
1908         }
1909         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1910         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1911         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1912         return ret_conv;
1913 }
1914 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1915         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1916         LDKTransaction closing_tx_var = closing_tx;
1917         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1918         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1919         Transaction_free(closing_tx_var);
1920         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1921         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1922         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1923         return ret_conv;
1924 }
1925 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1926         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1927         LDKUnsignedChannelAnnouncement msg_var = *msg;
1928         msg_var = UnsignedChannelAnnouncement_clone(msg);
1929         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1930         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1931         long msg_ref = (long)msg_var.inner;
1932         if (msg_var.is_owned) {
1933                 msg_ref |= 1;
1934         }
1935         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1936         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1937         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1938         return ret_conv;
1939 }
1940 void ready_channel_LDKSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1941         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1942         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1943         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1944         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1945         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1946         long channel_parameters_ref = (long)channel_parameters_var.inner;
1947         if (channel_parameters_var.is_owned) {
1948                 channel_parameters_ref |= 1;
1949         }
1950         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1951 }
1952 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1953         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1954         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1955         LDKCVec_u8Z ret_ref;
1956         ret_ref.datalen = *((uint32_t*)ret);
1957         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1958         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1959         return ret_ref;
1960 }
1961 static void* LDKSign_JCalls_clone(const void* this_arg) {
1962         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1963         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1964         return (void*) this_arg;
1965 }
1966 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1967         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1968         atomic_init(&calls->refcnt, 1);
1969         //TODO: Assign calls->o from o
1970
1971         LDKChannelPublicKeys pubkeys_conv;
1972         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1973         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1974         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1975
1976         LDKSign ret = {
1977                 .this_arg = (void*) calls,
1978                 .get_per_commitment_point = get_per_commitment_point_LDKSign_jcall,
1979                 .release_commitment_secret = release_commitment_secret_LDKSign_jcall,
1980                 .channel_keys_id = channel_keys_id_LDKSign_jcall,
1981                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKSign_jcall,
1982                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKSign_jcall,
1983                 .sign_justice_transaction = sign_justice_transaction_LDKSign_jcall,
1984                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKSign_jcall,
1985                 .sign_closing_transaction = sign_closing_transaction_LDKSign_jcall,
1986                 .sign_channel_announcement = sign_channel_announcement_LDKSign_jcall,
1987                 .ready_channel = ready_channel_LDKSign_jcall,
1988                 .clone = LDKSign_JCalls_clone,
1989                 .write = write_LDKSign_jcall,
1990                 .free = LDKSign_JCalls_free,
1991                 .pubkeys = pubkeys_conv,
1992                 .set_pubkeys = NULL,
1993         };
1994         return ret;
1995 }
1996 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1997         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1998         *res_ptr = LDKSign_init(o, pubkeys);
1999         return (long)res_ptr;
2000 }
2001 int8_tArray  __attribute__((visibility("default"))) TS_Sign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2002         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2003         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2004         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2005         return ret_arr;
2006 }
2007
2008 int8_tArray  __attribute__((visibility("default"))) TS_Sign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2009         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2010         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2011         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2012         return ret_arr;
2013 }
2014
2015 int8_tArray  __attribute__((visibility("default"))) TS_Sign_channel_keys_id(uint32_t this_arg) {
2016         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2017         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2018         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2019         return ret_arr;
2020 }
2021
2022 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2023         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2024         LDKCommitmentTransaction commitment_tx_conv;
2025         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2026         commitment_tx_conv.is_owned = false;
2027         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2028         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2029         return (long)ret_conv;
2030 }
2031
2032 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
2033         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2034         LDKHolderCommitmentTransaction commitment_tx_conv;
2035         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2036         commitment_tx_conv.is_owned = false;
2037         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2038         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2039         return (long)ret_conv;
2040 }
2041
2042 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_justice_transaction(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
2043         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2044         LDKTransaction justice_tx_ref;
2045         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2046         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2047         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2048         justice_tx_ref.data_is_owned = true;
2049         unsigned char per_commitment_key_arr[32];
2050         CHECK(*((uint32_t*)per_commitment_key) == 32);
2051         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2052         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2053         LDKHTLCOutputInCommitment htlc_conv;
2054         htlc_conv.inner = (void*)(htlc & (~1));
2055         htlc_conv.is_owned = false;
2056         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2057         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2058         return (long)ret_conv;
2059 }
2060
2061 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
2062         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2063         LDKTransaction htlc_tx_ref;
2064         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
2065         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2066         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
2067         htlc_tx_ref.data_is_owned = true;
2068         LDKPublicKey per_commitment_point_ref;
2069         CHECK(*((uint32_t*)per_commitment_point) == 33);
2070         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2071         LDKHTLCOutputInCommitment htlc_conv;
2072         htlc_conv.inner = (void*)(htlc & (~1));
2073         htlc_conv.is_owned = false;
2074         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2075         *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);
2076         return (long)ret_conv;
2077 }
2078
2079 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
2080         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2081         LDKTransaction closing_tx_ref;
2082         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
2083         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2084         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
2085         closing_tx_ref.data_is_owned = true;
2086         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2087         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2088         return (long)ret_conv;
2089 }
2090
2091 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2092         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2093         LDKUnsignedChannelAnnouncement msg_conv;
2094         msg_conv.inner = (void*)(msg & (~1));
2095         msg_conv.is_owned = false;
2096         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2097         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2098         return (long)ret_conv;
2099 }
2100
2101 void  __attribute__((visibility("default"))) TS_Sign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2102         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2103         LDKChannelTransactionParameters channel_parameters_conv;
2104         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2105         channel_parameters_conv.is_owned = false;
2106         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2107 }
2108
2109 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2110         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2111         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2112         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2113         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2114         CVec_u8Z_free(ret_var);
2115         return ret_arr;
2116 }
2117
2118 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2119         if (this_arg->set_pubkeys != NULL)
2120                 this_arg->set_pubkeys(this_arg);
2121         return this_arg->pubkeys;
2122 }
2123 uint32_t  __attribute__((visibility("default"))) TS_Sign_get_pubkeys(uint32_t this_arg) {
2124         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2125         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2126         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2127         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2128         long ret_ref = (long)ret_var.inner;
2129         if (ret_var.is_owned) {
2130                 ret_ref |= 1;
2131         }
2132         return ret_ref;
2133 }
2134
2135 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2136         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2137         LDKThirtyTwoBytes a_ref;
2138         CHECK(*((uint32_t*)a) == 32);
2139         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2140         ret->a = a_ref;
2141         LDKChannelMonitor b_conv;
2142         b_conv.inner = (void*)(b & (~1));
2143         b_conv.is_owned = (b & 1) || (b == 0);
2144         b_conv = ChannelMonitor_clone(&b_conv);
2145         ret->b = b_conv;
2146         return (long)ret;
2147 }
2148 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
2149         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2150         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2151         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2152         return a_arr;
2153 }
2154 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
2155         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2156         LDKChannelMonitor b_var = tuple->b;
2157         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2158         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2159         long b_ref = (long)b_var.inner & ~1;
2160         return b_ref;
2161 }
2162 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
2163         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2164 }
2165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
2166         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2167         CHECK(val->result_ok);
2168         long res_ref = (long)(&(*val->contents.result)) | 1;
2169         return res_ref;
2170 }
2171 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
2172         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2173         CHECK(!val->result_ok);
2174         LDKDecodeError err_var = (*val->contents.err);
2175         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2176         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2177         long err_ref = (long)err_var.inner & ~1;
2178         return err_ref;
2179 }
2180 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
2181         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2182 }
2183 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
2184         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2185         CHECK(val->result_ok);
2186         long res_ref = ((long)&(*val->contents.result)) | 1;
2187         return (long)res_ref;
2188 }
2189 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
2190         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2191         CHECK(!val->result_ok);
2192         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
2193         return err_conv;
2194 }
2195 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
2196         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2197         switch(obj->tag) {
2198                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2199                         long some_ref = (long)(&obj->some) | 1;
2200                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
2201                 }
2202                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2203                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
2204                 }
2205                 default: abort();
2206         }
2207 }
2208 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2209         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2210         switch(obj->tag) {
2211                 case LDKAPIError_APIMisuseError: {
2212                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2213                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2214                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2215                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
2216                 }
2217                 case LDKAPIError_FeeRateTooHigh: {
2218                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2219                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2220                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2221                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
2222                 }
2223                 case LDKAPIError_RouteError: {
2224                         LDKStr err_str = obj->route_error.err;
2225                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2226                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2227                 }
2228                 case LDKAPIError_ChannelUnavailable: {
2229                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2230                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2231                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2232                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
2233                 }
2234                 case LDKAPIError_MonitorUpdateFailed: {
2235                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2236                 }
2237                 default: abort();
2238         }
2239 }
2240 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2241         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2242 }
2243 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2244         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2245         CHECK(val->result_ok);
2246         return *val->contents.result;
2247 }
2248 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2249         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2250         CHECK(!val->result_ok);
2251         long err_ref = ((long)&(*val->contents.err)) | 1;
2252         return err_ref;
2253 }
2254 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2255         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2256         ret->datalen = *((uint32_t*)elems);
2257         if (ret->datalen == 0) {
2258                 ret->data = NULL;
2259         } else {
2260                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2261                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2262                 for (size_t i = 0; i < ret->datalen; i++) {
2263                         uint32_t arr_elem = java_elems[i];
2264                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2265                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2266                         ret->data[i] = arr_elem_conv;
2267                 }
2268         }
2269         return (long)ret;
2270 }
2271 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2272         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2273         for (size_t i = 0; i < ret.datalen; i++) {
2274                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2275         }
2276         return ret;
2277 }
2278 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2279         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2280         ret->datalen = *((uint32_t*)elems);
2281         if (ret->datalen == 0) {
2282                 ret->data = NULL;
2283         } else {
2284                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2285                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2286                 for (size_t i = 0; i < ret->datalen; i++) {
2287                         uint32_t arr_elem = java_elems[i];
2288                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2289                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2290                         ret->data[i] = arr_elem_conv;
2291                 }
2292         }
2293         return (long)ret;
2294 }
2295 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2296         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2297         for (size_t i = 0; i < ret.datalen; i++) {
2298                 ret.data[i] = APIError_clone(&orig->data[i]);
2299         }
2300         return ret;
2301 }
2302 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
2303         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2304         ret->datalen = *((uint32_t*)elems);
2305         if (ret->datalen == 0) {
2306                 ret->data = NULL;
2307         } else {
2308                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2309                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2310                 for (size_t i = 0; i < ret->datalen; i++) {
2311                         uint32_t arr_elem = java_elems[i];
2312                         LDKChannelDetails arr_elem_conv;
2313                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2314                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2315                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2316                         ret->data[i] = arr_elem_conv;
2317                 }
2318         }
2319         return (long)ret;
2320 }
2321 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2322         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2323         for (size_t i = 0; i < ret.datalen; i++) {
2324                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2325         }
2326         return ret;
2327 }
2328 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2329         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2330         switch(obj->tag) {
2331                 case LDKPaymentSendFailure_ParameterError: {
2332                         long parameter_error_ref = ((long)&obj->parameter_error) | 1;
2333                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2334                 }
2335                 case LDKPaymentSendFailure_PathParameterError: {
2336                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2337                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2338                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2339                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2340                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2341                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2342                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2343                                 path_parameter_error_arr_ptr[w] = (long)path_parameter_error_conv_22_conv;
2344                         }
2345                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2346                 }
2347                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2348                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2349                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2350                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2351                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2352                                 long all_failed_retry_safe_conv_10_ref = ((long)&all_failed_retry_safe_var.data[k]) | 1;
2353                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2354                         }
2355                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2356                 }
2357                 case LDKPaymentSendFailure_PartialFailure: {
2358                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2359                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2360                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2361                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2362                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2363                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2364                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2365                                 partial_failure_arr_ptr[w] = (long)partial_failure_conv_22_conv;
2366                         }
2367                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2368                 }
2369                 default: abort();
2370         }
2371 }
2372 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2373         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2374 }
2375 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2376         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2377         CHECK(val->result_ok);
2378         return *val->contents.result;
2379 }
2380 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2381         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2382         CHECK(!val->result_ok);
2383         long err_ref = ((long)&(*val->contents.err)) | 1;
2384         return err_ref;
2385 }
2386 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2387         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2388         ret->datalen = *((uint32_t*)elems);
2389         if (ret->datalen == 0) {
2390                 ret->data = NULL;
2391         } else {
2392                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2393                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2394                 for (size_t i = 0; i < ret->datalen; i++) {
2395                         uint32_t arr_elem = java_elems[i];
2396                         LDKChannelMonitor arr_elem_conv;
2397                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2398                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2399                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2400                         ret->data[i] = arr_elem_conv;
2401                 }
2402         }
2403         return (long)ret;
2404 }
2405 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2406         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2407         for (size_t i = 0; i < ret.datalen; i++) {
2408                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2409         }
2410         return ret;
2411 }
2412 typedef struct LDKWatch_JCalls {
2413         atomic_size_t refcnt;
2414         uint32_t watch_channel_meth;
2415         uint32_t update_channel_meth;
2416         uint32_t release_pending_monitor_events_meth;
2417 } LDKWatch_JCalls;
2418 static void LDKWatch_JCalls_free(void* this_arg) {
2419         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2420         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2421                 js_free(j_calls->watch_channel_meth);
2422                 js_free(j_calls->update_channel_meth);
2423                 js_free(j_calls->release_pending_monitor_events_meth);
2424                 FREE(j_calls);
2425         }
2426 }
2427 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2428         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2429         LDKOutPoint funding_txo_var = funding_txo;
2430         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2431         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2432         long funding_txo_ref = (long)funding_txo_var.inner;
2433         if (funding_txo_var.is_owned) {
2434                 funding_txo_ref |= 1;
2435         }
2436         LDKChannelMonitor monitor_var = monitor;
2437         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2438         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2439         long monitor_ref = (long)monitor_var.inner;
2440         if (monitor_var.is_owned) {
2441                 monitor_ref |= 1;
2442         }
2443         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2444         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2445         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2446         return ret_conv;
2447 }
2448 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2449         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2450         LDKOutPoint funding_txo_var = funding_txo;
2451         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2452         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2453         long funding_txo_ref = (long)funding_txo_var.inner;
2454         if (funding_txo_var.is_owned) {
2455                 funding_txo_ref |= 1;
2456         }
2457         LDKChannelMonitorUpdate update_var = update;
2458         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2459         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2460         long update_ref = (long)update_var.inner;
2461         if (update_var.is_owned) {
2462                 update_ref |= 1;
2463         }
2464         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2465         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2466         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2467         return ret_conv;
2468 }
2469 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2470         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2471         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2472         LDKCVec_MonitorEventZ ret_constr;
2473         ret_constr.datalen = *((uint32_t*)ret);
2474         if (ret_constr.datalen > 0)
2475                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2476         else
2477                 ret_constr.data = NULL;
2478         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2479         for (size_t o = 0; o < ret_constr.datalen; o++) {
2480                 uint32_t ret_conv_14 = ret_vals[o];
2481                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2482                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2483                 ret_constr.data[o] = ret_conv_14_conv;
2484         }
2485         return ret_constr;
2486 }
2487 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2488         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2489         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2490         return (void*) this_arg;
2491 }
2492 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2493         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2494         atomic_init(&calls->refcnt, 1);
2495         //TODO: Assign calls->o from o
2496
2497         LDKWatch ret = {
2498                 .this_arg = (void*) calls,
2499                 .watch_channel = watch_channel_LDKWatch_jcall,
2500                 .update_channel = update_channel_LDKWatch_jcall,
2501                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2502                 .free = LDKWatch_JCalls_free,
2503         };
2504         return ret;
2505 }
2506 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2507         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2508         *res_ptr = LDKWatch_init(o);
2509         return (long)res_ptr;
2510 }
2511 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2512         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2513         LDKOutPoint funding_txo_conv;
2514         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2515         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2516         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2517         LDKChannelMonitor monitor_conv;
2518         monitor_conv.inner = (void*)(monitor & (~1));
2519         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2520         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2521         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2522         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2523         return (long)ret_conv;
2524 }
2525
2526 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2527         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2528         LDKOutPoint funding_txo_conv;
2529         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2530         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2531         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2532         LDKChannelMonitorUpdate update_conv;
2533         update_conv.inner = (void*)(update & (~1));
2534         update_conv.is_owned = (update & 1) || (update == 0);
2535         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2536         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2537         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2538         return (long)ret_conv;
2539 }
2540
2541 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2542         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2543         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2544         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2545         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2546         for (size_t o = 0; o < ret_var.datalen; o++) {
2547                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2548                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2549                 long ret_conv_14_ref = (long)ret_conv_14_copy;
2550                 ret_arr_ptr[o] = ret_conv_14_ref;
2551         }
2552         FREE(ret_var.data);
2553         return ret_arr;
2554 }
2555
2556 typedef struct LDKBroadcasterInterface_JCalls {
2557         atomic_size_t refcnt;
2558         uint32_t broadcast_transaction_meth;
2559 } LDKBroadcasterInterface_JCalls;
2560 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2561         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2562         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2563                 js_free(j_calls->broadcast_transaction_meth);
2564                 FREE(j_calls);
2565         }
2566 }
2567 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2568         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2569         LDKTransaction tx_var = tx;
2570         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2571         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2572         Transaction_free(tx_var);
2573         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2574 }
2575 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2576         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2577         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2578         return (void*) this_arg;
2579 }
2580 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2581         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2582         atomic_init(&calls->refcnt, 1);
2583         //TODO: Assign calls->o from o
2584
2585         LDKBroadcasterInterface ret = {
2586                 .this_arg = (void*) calls,
2587                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2588                 .free = LDKBroadcasterInterface_JCalls_free,
2589         };
2590         return ret;
2591 }
2592 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2593         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2594         *res_ptr = LDKBroadcasterInterface_init(o);
2595         return (long)res_ptr;
2596 }
2597 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2598         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2599         LDKTransaction tx_ref;
2600         tx_ref.datalen = *((uint32_t*)tx);
2601         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2602         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2603         tx_ref.data_is_owned = true;
2604         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2605 }
2606
2607 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
2608         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2609 }
2610 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2611         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2612         CHECK(val->result_ok);
2613         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2614         *ret = Sign_clone(&(*val->contents.result));
2615         return (long)ret;
2616 }
2617 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2618         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2619         CHECK(!val->result_ok);
2620         LDKDecodeError err_var = (*val->contents.err);
2621         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2622         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2623         long err_ref = (long)err_var.inner & ~1;
2624         return err_ref;
2625 }
2626 typedef struct LDKKeysInterface_JCalls {
2627         atomic_size_t refcnt;
2628         uint32_t get_node_secret_meth;
2629         uint32_t get_destination_script_meth;
2630         uint32_t get_shutdown_pubkey_meth;
2631         uint32_t get_channel_signer_meth;
2632         uint32_t get_secure_random_bytes_meth;
2633         uint32_t read_chan_signer_meth;
2634 } LDKKeysInterface_JCalls;
2635 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2636         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2637         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2638                 js_free(j_calls->get_node_secret_meth);
2639                 js_free(j_calls->get_destination_script_meth);
2640                 js_free(j_calls->get_shutdown_pubkey_meth);
2641                 js_free(j_calls->get_channel_signer_meth);
2642                 js_free(j_calls->get_secure_random_bytes_meth);
2643                 js_free(j_calls->read_chan_signer_meth);
2644                 FREE(j_calls);
2645         }
2646 }
2647 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2648         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2649         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2650         LDKSecretKey ret_ref;
2651         CHECK(*((uint32_t*)ret) == 32);
2652         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2653         return ret_ref;
2654 }
2655 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2656         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2657         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2658         LDKCVec_u8Z ret_ref;
2659         ret_ref.datalen = *((uint32_t*)ret);
2660         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2661         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2662         return ret_ref;
2663 }
2664 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
2665         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2666         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2667         LDKPublicKey ret_ref;
2668         CHECK(*((uint32_t*)ret) == 33);
2669         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2670         return ret_ref;
2671 }
2672 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2673         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2674         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2675         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2676         ret_conv = Sign_clone(ret);
2677         return ret_conv;
2678 }
2679 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2680         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2681         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2682         LDKThirtyTwoBytes ret_ref;
2683         CHECK(*((uint32_t*)ret) == 32);
2684         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2685         return ret_ref;
2686 }
2687 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2688         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2689         LDKu8slice reader_var = reader;
2690         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2691         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2692         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2693         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2694         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2695         return ret_conv;
2696 }
2697 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2698         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2699         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2700         return (void*) this_arg;
2701 }
2702 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2703         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2704         atomic_init(&calls->refcnt, 1);
2705         //TODO: Assign calls->o from o
2706
2707         LDKKeysInterface ret = {
2708                 .this_arg = (void*) calls,
2709                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2710                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2711                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
2712                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2713                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2714                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2715                 .free = LDKKeysInterface_JCalls_free,
2716         };
2717         return ret;
2718 }
2719 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2720         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2721         *res_ptr = LDKKeysInterface_init(o);
2722         return (long)res_ptr;
2723 }
2724 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2725         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2726         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2727         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2728         return ret_arr;
2729 }
2730
2731 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2732         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2733         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2734         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2735         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2736         CVec_u8Z_free(ret_var);
2737         return ret_arr;
2738 }
2739
2740 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2741         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2742         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2743         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2744         return ret_arr;
2745 }
2746
2747 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2748         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2749         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2750         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2751         return (long)ret;
2752 }
2753
2754 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2755         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2756         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2757         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2758         return ret_arr;
2759 }
2760
2761 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2762         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2763         LDKu8slice reader_ref;
2764         reader_ref.datalen = *((uint32_t*)reader);
2765         reader_ref.data = (int8_t*)(reader + 4);
2766         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2767         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2768         return (long)ret_conv;
2769 }
2770
2771 typedef struct LDKFeeEstimator_JCalls {
2772         atomic_size_t refcnt;
2773         uint32_t get_est_sat_per_1000_weight_meth;
2774 } LDKFeeEstimator_JCalls;
2775 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2776         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2777         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2778                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2779                 FREE(j_calls);
2780         }
2781 }
2782 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2783         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2784         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2785         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2786 }
2787 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2788         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2789         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2790         return (void*) this_arg;
2791 }
2792 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2793         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2794         atomic_init(&calls->refcnt, 1);
2795         //TODO: Assign calls->o from o
2796
2797         LDKFeeEstimator ret = {
2798                 .this_arg = (void*) calls,
2799                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2800                 .free = LDKFeeEstimator_JCalls_free,
2801         };
2802         return ret;
2803 }
2804 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2805         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2806         *res_ptr = LDKFeeEstimator_init(o);
2807         return (long)res_ptr;
2808 }
2809 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2810         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2811         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2812         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2813         return ret_val;
2814 }
2815
2816 typedef struct LDKLogger_JCalls {
2817         atomic_size_t refcnt;
2818         uint32_t log_meth;
2819 } LDKLogger_JCalls;
2820 static void LDKLogger_JCalls_free(void* this_arg) {
2821         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2822         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2823                 js_free(j_calls->log_meth);
2824                 FREE(j_calls);
2825         }
2826 }
2827 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2828         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2829         const char* record_str = record;
2830         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2831         js_invoke_function_1(j_calls->log_meth, record_conv);
2832 }
2833 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2834         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2835         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2836         return (void*) this_arg;
2837 }
2838 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2839         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2840         atomic_init(&calls->refcnt, 1);
2841         //TODO: Assign calls->o from o
2842
2843         LDKLogger ret = {
2844                 .this_arg = (void*) calls,
2845                 .log = log_LDKLogger_jcall,
2846                 .free = LDKLogger_JCalls_free,
2847         };
2848         return ret;
2849 }
2850 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2851         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2852         *res_ptr = LDKLogger_init(o);
2853         return (long)res_ptr;
2854 }
2855 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2856         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2857         LDKThirtyTwoBytes a_ref;
2858         CHECK(*((uint32_t*)a) == 32);
2859         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2860         ret->a = a_ref;
2861         LDKChannelManager b_conv;
2862         b_conv.inner = (void*)(b & (~1));
2863         b_conv.is_owned = (b & 1) || (b == 0);
2864         // Warning: we need a move here but no clone is available for LDKChannelManager
2865         ret->b = b_conv;
2866         return (long)ret;
2867 }
2868 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2869         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2870         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2871         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2872         return a_arr;
2873 }
2874 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2875         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2876         LDKChannelManager b_var = tuple->b;
2877         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2878         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2879         long b_ref = (long)b_var.inner & ~1;
2880         return b_ref;
2881 }
2882 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2883         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2884 }
2885 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2886         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2887         CHECK(val->result_ok);
2888         long res_ref = (long)(&(*val->contents.result)) | 1;
2889         return res_ref;
2890 }
2891 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2892         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2893         CHECK(!val->result_ok);
2894         LDKDecodeError err_var = (*val->contents.err);
2895         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2896         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2897         long err_ref = (long)err_var.inner & ~1;
2898         return err_ref;
2899 }
2900 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
2901         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2902 }
2903 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
2904         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2905         CHECK(val->result_ok);
2906         long res_ref = ((long)&(*val->contents.result)) | 1;
2907         return res_ref;
2908 }
2909 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
2910         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2911         CHECK(!val->result_ok);
2912         LDKDecodeError err_var = (*val->contents.err);
2913         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2914         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2915         long err_ref = (long)err_var.inner & ~1;
2916         return err_ref;
2917 }
2918 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2919         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2920         for (size_t i = 0; i < ret.datalen; i++) {
2921                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2922         }
2923         return ret;
2924 }
2925 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2926         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2927 }
2928 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2929         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2930         CHECK(val->result_ok);
2931         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2932         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2933         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2934         for (size_t m = 0; m < res_var.datalen; m++) {
2935                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2936                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2937                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2938                 res_arr_ptr[m] = res_conv_12_arr;
2939         }
2940         return res_arr;
2941 }
2942 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2943         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2944         CHECK(!val->result_ok);
2945         return *val->contents.err;
2946 }
2947 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2948         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2949 }
2950 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2951         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2952         CHECK(val->result_ok);
2953         LDKInMemorySigner res_var = (*val->contents.result);
2954         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2955         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2956         long res_ref = (long)res_var.inner & ~1;
2957         return res_ref;
2958 }
2959 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2960         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2961         CHECK(!val->result_ok);
2962         LDKDecodeError err_var = (*val->contents.err);
2963         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2964         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2965         long err_ref = (long)err_var.inner & ~1;
2966         return err_ref;
2967 }
2968 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2969         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2970         ret->datalen = *((uint32_t*)elems);
2971         if (ret->datalen == 0) {
2972                 ret->data = NULL;
2973         } else {
2974                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2975                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2976                 for (size_t i = 0; i < ret->datalen; i++) {
2977                         uint32_t arr_elem = java_elems[i];
2978                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2979                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2980                         ret->data[i] = arr_elem_conv;
2981                 }
2982         }
2983         return (long)ret;
2984 }
2985 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2986         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2987         for (size_t i = 0; i < ret.datalen; i++) {
2988                 ret.data[i] = TxOut_clone(&orig->data[i]);
2989         }
2990         return ret;
2991 }
2992 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2993         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2994 }
2995 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2996         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2997         CHECK(val->result_ok);
2998         LDKTransaction res_var = (*val->contents.result);
2999         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3000         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3001         return res_arr;
3002 }
3003 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
3004         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3005         CHECK(!val->result_ok);
3006         return *val->contents.err;
3007 }
3008 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
3009         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
3010         ret->datalen = *((uint32_t*)elems);
3011         if (ret->datalen == 0) {
3012                 ret->data = NULL;
3013         } else {
3014                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
3015                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3016                 for (size_t i = 0; i < ret->datalen; i++) {
3017                         uint32_t arr_elem = java_elems[i];
3018                         LDKRouteHop arr_elem_conv;
3019                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3020                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3021                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
3022                         ret->data[i] = arr_elem_conv;
3023                 }
3024         }
3025         return (long)ret;
3026 }
3027 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3028         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3029         for (size_t i = 0; i < ret.datalen; i++) {
3030                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3031         }
3032         return ret;
3033 }
3034 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
3035         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
3036         for (size_t i = 0; i < ret.datalen; i++) {
3037                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
3038         }
3039         return ret;
3040 }
3041 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
3042         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
3043 }
3044 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
3045         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3046         CHECK(val->result_ok);
3047         LDKRoute res_var = (*val->contents.result);
3048         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3049         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3050         long res_ref = (long)res_var.inner & ~1;
3051         return res_ref;
3052 }
3053 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
3054         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
3055         CHECK(!val->result_ok);
3056         LDKDecodeError err_var = (*val->contents.err);
3057         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3058         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3059         long err_ref = (long)err_var.inner & ~1;
3060         return err_ref;
3061 }
3062 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
3063         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
3064         ret->datalen = *((uint32_t*)elems);
3065         if (ret->datalen == 0) {
3066                 ret->data = NULL;
3067         } else {
3068                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
3069                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3070                 for (size_t i = 0; i < ret->datalen; i++) {
3071                         uint32_t arr_elem = java_elems[i];
3072                         LDKRouteHint arr_elem_conv;
3073                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3074                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3075                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
3076                         ret->data[i] = arr_elem_conv;
3077                 }
3078         }
3079         return (long)ret;
3080 }
3081 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3082         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3083         for (size_t i = 0; i < ret.datalen; i++) {
3084                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3085         }
3086         return ret;
3087 }
3088 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
3089         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3090 }
3091 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
3092         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3093         CHECK(val->result_ok);
3094         LDKRoute res_var = (*val->contents.result);
3095         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3096         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3097         long res_ref = (long)res_var.inner & ~1;
3098         return res_ref;
3099 }
3100 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
3101         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3102         CHECK(!val->result_ok);
3103         LDKLightningError err_var = (*val->contents.err);
3104         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3105         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3106         long err_ref = (long)err_var.inner & ~1;
3107         return err_ref;
3108 }
3109 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3110         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3111 }
3112 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3113         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3114         CHECK(val->result_ok);
3115         long res_ref = ((long)&(*val->contents.result)) | 1;
3116         return res_ref;
3117 }
3118 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3119         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3120         CHECK(!val->result_ok);
3121         return *val->contents.err;
3122 }
3123 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3124         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3125 }
3126 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3127         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3128         CHECK(val->result_ok);
3129         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3130         *res_conv = (*val->contents.result);
3131         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3132         return (long)res_conv;
3133 }
3134 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3135         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3136         CHECK(!val->result_ok);
3137         LDKDecodeError err_var = (*val->contents.err);
3138         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3139         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3140         long err_ref = (long)err_var.inner & ~1;
3141         return err_ref;
3142 }
3143 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3144         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3145         ret->datalen = *((uint32_t*)elems);
3146         if (ret->datalen == 0) {
3147                 ret->data = NULL;
3148         } else {
3149                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3150                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3151                 for (size_t i = 0; i < ret->datalen; i++) {
3152                         uint32_t arr_elem = java_elems[i];
3153                         LDKUpdateAddHTLC arr_elem_conv;
3154                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3155                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3156                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3157                         ret->data[i] = arr_elem_conv;
3158                 }
3159         }
3160         return (long)ret;
3161 }
3162 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3163         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3164         for (size_t i = 0; i < ret.datalen; i++) {
3165                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3166         }
3167         return ret;
3168 }
3169 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3170         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3171         ret->datalen = *((uint32_t*)elems);
3172         if (ret->datalen == 0) {
3173                 ret->data = NULL;
3174         } else {
3175                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3176                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3177                 for (size_t i = 0; i < ret->datalen; i++) {
3178                         uint32_t arr_elem = java_elems[i];
3179                         LDKUpdateFulfillHTLC arr_elem_conv;
3180                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3181                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3182                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3183                         ret->data[i] = arr_elem_conv;
3184                 }
3185         }
3186         return (long)ret;
3187 }
3188 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3189         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3190         for (size_t i = 0; i < ret.datalen; i++) {
3191                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3192         }
3193         return ret;
3194 }
3195 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3196         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3197         ret->datalen = *((uint32_t*)elems);
3198         if (ret->datalen == 0) {
3199                 ret->data = NULL;
3200         } else {
3201                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3202                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3203                 for (size_t i = 0; i < ret->datalen; i++) {
3204                         uint32_t arr_elem = java_elems[i];
3205                         LDKUpdateFailHTLC 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 = UpdateFailHTLC_clone(&arr_elem_conv);
3209                         ret->data[i] = arr_elem_conv;
3210                 }
3211         }
3212         return (long)ret;
3213 }
3214 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3215         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3216         for (size_t i = 0; i < ret.datalen; i++) {
3217                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3218         }
3219         return ret;
3220 }
3221 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3222         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3223         ret->datalen = *((uint32_t*)elems);
3224         if (ret->datalen == 0) {
3225                 ret->data = NULL;
3226         } else {
3227                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3228                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3229                 for (size_t i = 0; i < ret->datalen; i++) {
3230                         uint32_t arr_elem = java_elems[i];
3231                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3232                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3233                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3234                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3235                         ret->data[i] = arr_elem_conv;
3236                 }
3237         }
3238         return (long)ret;
3239 }
3240 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3241         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3242         for (size_t i = 0; i < ret.datalen; i++) {
3243                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3244         }
3245         return ret;
3246 }
3247 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3248         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3249 }
3250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3251         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3252         CHECK(val->result_ok);
3253         LDKAcceptChannel res_var = (*val->contents.result);
3254         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3255         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3256         long res_ref = (long)res_var.inner & ~1;
3257         return res_ref;
3258 }
3259 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3260         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3261         CHECK(!val->result_ok);
3262         LDKDecodeError err_var = (*val->contents.err);
3263         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3264         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3265         long err_ref = (long)err_var.inner & ~1;
3266         return err_ref;
3267 }
3268 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3269         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3270 }
3271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3272         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3273         CHECK(val->result_ok);
3274         LDKAnnouncementSignatures res_var = (*val->contents.result);
3275         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3276         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3277         long res_ref = (long)res_var.inner & ~1;
3278         return res_ref;
3279 }
3280 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3281         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3282         CHECK(!val->result_ok);
3283         LDKDecodeError err_var = (*val->contents.err);
3284         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3285         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3286         long err_ref = (long)err_var.inner & ~1;
3287         return err_ref;
3288 }
3289 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
3290         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3291 }
3292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
3293         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3294         CHECK(val->result_ok);
3295         LDKChannelReestablish res_var = (*val->contents.result);
3296         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3297         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3298         long res_ref = (long)res_var.inner & ~1;
3299         return res_ref;
3300 }
3301 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
3302         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3303         CHECK(!val->result_ok);
3304         LDKDecodeError err_var = (*val->contents.err);
3305         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3306         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3307         long err_ref = (long)err_var.inner & ~1;
3308         return err_ref;
3309 }
3310 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3311         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3312 }
3313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3314         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3315         CHECK(val->result_ok);
3316         LDKClosingSigned res_var = (*val->contents.result);
3317         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3318         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3319         long res_ref = (long)res_var.inner & ~1;
3320         return res_ref;
3321 }
3322 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
3323         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3324         CHECK(!val->result_ok);
3325         LDKDecodeError err_var = (*val->contents.err);
3326         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3327         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3328         long err_ref = (long)err_var.inner & ~1;
3329         return err_ref;
3330 }
3331 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
3332         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3333 }
3334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
3335         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3336         CHECK(val->result_ok);
3337         LDKCommitmentSigned res_var = (*val->contents.result);
3338         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3339         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3340         long res_ref = (long)res_var.inner & ~1;
3341         return res_ref;
3342 }
3343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
3344         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3345         CHECK(!val->result_ok);
3346         LDKDecodeError err_var = (*val->contents.err);
3347         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3348         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3349         long err_ref = (long)err_var.inner & ~1;
3350         return err_ref;
3351 }
3352 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
3353         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3354 }
3355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
3356         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3357         CHECK(val->result_ok);
3358         LDKFundingCreated res_var = (*val->contents.result);
3359         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3360         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3361         long res_ref = (long)res_var.inner & ~1;
3362         return res_ref;
3363 }
3364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
3365         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3366         CHECK(!val->result_ok);
3367         LDKDecodeError err_var = (*val->contents.err);
3368         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3369         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3370         long err_ref = (long)err_var.inner & ~1;
3371         return err_ref;
3372 }
3373 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3374         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3375 }
3376 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3377         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3378         CHECK(val->result_ok);
3379         LDKFundingSigned res_var = (*val->contents.result);
3380         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3381         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3382         long res_ref = (long)res_var.inner & ~1;
3383         return res_ref;
3384 }
3385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
3386         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3387         CHECK(!val->result_ok);
3388         LDKDecodeError err_var = (*val->contents.err);
3389         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3390         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3391         long err_ref = (long)err_var.inner & ~1;
3392         return err_ref;
3393 }
3394 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
3395         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3396 }
3397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
3398         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3399         CHECK(val->result_ok);
3400         LDKFundingLocked res_var = (*val->contents.result);
3401         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3402         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3403         long res_ref = (long)res_var.inner & ~1;
3404         return res_ref;
3405 }
3406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
3407         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3408         CHECK(!val->result_ok);
3409         LDKDecodeError err_var = (*val->contents.err);
3410         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3411         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3412         long err_ref = (long)err_var.inner & ~1;
3413         return err_ref;
3414 }
3415 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
3416         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3417 }
3418 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
3419         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3420         CHECK(val->result_ok);
3421         LDKInit res_var = (*val->contents.result);
3422         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3423         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3424         long res_ref = (long)res_var.inner & ~1;
3425         return res_ref;
3426 }
3427 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
3428         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3429         CHECK(!val->result_ok);
3430         LDKDecodeError err_var = (*val->contents.err);
3431         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3432         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3433         long err_ref = (long)err_var.inner & ~1;
3434         return err_ref;
3435 }
3436 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
3437         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3438 }
3439 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
3440         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3441         CHECK(val->result_ok);
3442         LDKOpenChannel res_var = (*val->contents.result);
3443         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3444         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3445         long res_ref = (long)res_var.inner & ~1;
3446         return res_ref;
3447 }
3448 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
3449         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3450         CHECK(!val->result_ok);
3451         LDKDecodeError err_var = (*val->contents.err);
3452         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3453         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3454         long err_ref = (long)err_var.inner & ~1;
3455         return err_ref;
3456 }
3457 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
3458         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3459 }
3460 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
3461         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3462         CHECK(val->result_ok);
3463         LDKRevokeAndACK res_var = (*val->contents.result);
3464         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3465         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3466         long res_ref = (long)res_var.inner & ~1;
3467         return res_ref;
3468 }
3469 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
3470         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3471         CHECK(!val->result_ok);
3472         LDKDecodeError err_var = (*val->contents.err);
3473         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3474         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3475         long err_ref = (long)err_var.inner & ~1;
3476         return err_ref;
3477 }
3478 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
3479         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3480 }
3481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
3482         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3483         CHECK(val->result_ok);
3484         LDKShutdown res_var = (*val->contents.result);
3485         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3486         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3487         long res_ref = (long)res_var.inner & ~1;
3488         return res_ref;
3489 }
3490 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
3491         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3492         CHECK(!val->result_ok);
3493         LDKDecodeError err_var = (*val->contents.err);
3494         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3495         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3496         long err_ref = (long)err_var.inner & ~1;
3497         return err_ref;
3498 }
3499 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3500         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3501 }
3502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3503         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3504         CHECK(val->result_ok);
3505         LDKUpdateFailHTLC res_var = (*val->contents.result);
3506         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3507         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3508         long res_ref = (long)res_var.inner & ~1;
3509         return res_ref;
3510 }
3511 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
3512         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3513         CHECK(!val->result_ok);
3514         LDKDecodeError err_var = (*val->contents.err);
3515         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3516         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3517         long err_ref = (long)err_var.inner & ~1;
3518         return err_ref;
3519 }
3520 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3521         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3522 }
3523 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3524         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3525         CHECK(val->result_ok);
3526         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
3527         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3528         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3529         long res_ref = (long)res_var.inner & ~1;
3530         return res_ref;
3531 }
3532 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
3533         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3534         CHECK(!val->result_ok);
3535         LDKDecodeError err_var = (*val->contents.err);
3536         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3537         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3538         long err_ref = (long)err_var.inner & ~1;
3539         return err_ref;
3540 }
3541 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
3542         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3543 }
3544 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
3545         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3546         CHECK(val->result_ok);
3547         LDKUpdateFee res_var = (*val->contents.result);
3548         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3549         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3550         long res_ref = (long)res_var.inner & ~1;
3551         return res_ref;
3552 }
3553 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
3554         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3555         CHECK(!val->result_ok);
3556         LDKDecodeError err_var = (*val->contents.err);
3557         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3558         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3559         long err_ref = (long)err_var.inner & ~1;
3560         return err_ref;
3561 }
3562 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3563         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3564 }
3565 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3566         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3567         CHECK(val->result_ok);
3568         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
3569         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3570         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3571         long res_ref = (long)res_var.inner & ~1;
3572         return res_ref;
3573 }
3574 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
3575         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3576         CHECK(!val->result_ok);
3577         LDKDecodeError err_var = (*val->contents.err);
3578         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3579         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3580         long err_ref = (long)err_var.inner & ~1;
3581         return err_ref;
3582 }
3583 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3584         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3585 }
3586 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3587         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3588         CHECK(val->result_ok);
3589         LDKUpdateAddHTLC res_var = (*val->contents.result);
3590         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3591         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3592         long res_ref = (long)res_var.inner & ~1;
3593         return res_ref;
3594 }
3595 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
3596         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3597         CHECK(!val->result_ok);
3598         LDKDecodeError err_var = (*val->contents.err);
3599         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3600         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3601         long err_ref = (long)err_var.inner & ~1;
3602         return err_ref;
3603 }
3604 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
3605         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3606 }
3607 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
3608         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3609         CHECK(val->result_ok);
3610         LDKPing res_var = (*val->contents.result);
3611         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3612         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3613         long res_ref = (long)res_var.inner & ~1;
3614         return res_ref;
3615 }
3616 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
3617         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3618         CHECK(!val->result_ok);
3619         LDKDecodeError err_var = (*val->contents.err);
3620         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3621         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3622         long err_ref = (long)err_var.inner & ~1;
3623         return err_ref;
3624 }
3625 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
3626         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
3627 }
3628 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
3629         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3630         CHECK(val->result_ok);
3631         LDKPong res_var = (*val->contents.result);
3632         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3633         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3634         long res_ref = (long)res_var.inner & ~1;
3635         return res_ref;
3636 }
3637 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
3638         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3639         CHECK(!val->result_ok);
3640         LDKDecodeError err_var = (*val->contents.err);
3641         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3642         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3643         long err_ref = (long)err_var.inner & ~1;
3644         return err_ref;
3645 }
3646 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3647         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3648 }
3649 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3650         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3651         CHECK(val->result_ok);
3652         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
3653         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3654         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3655         long res_ref = (long)res_var.inner & ~1;
3656         return res_ref;
3657 }
3658 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3659         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3660         CHECK(!val->result_ok);
3661         LDKDecodeError err_var = (*val->contents.err);
3662         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3663         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3664         long err_ref = (long)err_var.inner & ~1;
3665         return err_ref;
3666 }
3667 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3668         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3669 }
3670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3671         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3672         CHECK(val->result_ok);
3673         LDKChannelAnnouncement res_var = (*val->contents.result);
3674         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3675         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3676         long res_ref = (long)res_var.inner & ~1;
3677         return res_ref;
3678 }
3679 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3680         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3681         CHECK(!val->result_ok);
3682         LDKDecodeError err_var = (*val->contents.err);
3683         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3684         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3685         long err_ref = (long)err_var.inner & ~1;
3686         return err_ref;
3687 }
3688 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3689         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
3690 }
3691 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3692         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3693         CHECK(val->result_ok);
3694         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
3695         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3696         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3697         long res_ref = (long)res_var.inner & ~1;
3698         return res_ref;
3699 }
3700 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3701         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3702         CHECK(!val->result_ok);
3703         LDKDecodeError err_var = (*val->contents.err);
3704         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3705         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3706         long err_ref = (long)err_var.inner & ~1;
3707         return err_ref;
3708 }
3709 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3710         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3711 }
3712 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3713         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3714         CHECK(val->result_ok);
3715         LDKChannelUpdate res_var = (*val->contents.result);
3716         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3717         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3718         long res_ref = (long)res_var.inner & ~1;
3719         return res_ref;
3720 }
3721 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3722         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3723         CHECK(!val->result_ok);
3724         LDKDecodeError err_var = (*val->contents.err);
3725         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3726         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3727         long err_ref = (long)err_var.inner & ~1;
3728         return err_ref;
3729 }
3730 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
3731         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3732 }
3733 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
3734         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3735         CHECK(val->result_ok);
3736         LDKErrorMessage res_var = (*val->contents.result);
3737         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3738         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3739         long res_ref = (long)res_var.inner & ~1;
3740         return res_ref;
3741 }
3742 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
3743         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3744         CHECK(!val->result_ok);
3745         LDKDecodeError err_var = (*val->contents.err);
3746         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3747         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3748         long err_ref = (long)err_var.inner & ~1;
3749         return err_ref;
3750 }
3751 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3752         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3753 }
3754 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3755         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3756         CHECK(val->result_ok);
3757         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
3758         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3759         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3760         long res_ref = (long)res_var.inner & ~1;
3761         return res_ref;
3762 }
3763 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3764         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3765         CHECK(!val->result_ok);
3766         LDKDecodeError err_var = (*val->contents.err);
3767         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3768         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3769         long err_ref = (long)err_var.inner & ~1;
3770         return err_ref;
3771 }
3772 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3773         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3774 }
3775 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3776         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3777         CHECK(val->result_ok);
3778         LDKNodeAnnouncement res_var = (*val->contents.result);
3779         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3780         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3781         long res_ref = (long)res_var.inner & ~1;
3782         return res_ref;
3783 }
3784 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3785         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3786         CHECK(!val->result_ok);
3787         LDKDecodeError err_var = (*val->contents.err);
3788         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3789         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3790         long err_ref = (long)err_var.inner & ~1;
3791         return err_ref;
3792 }
3793 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
3794         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3795 }
3796 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
3797         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3798         CHECK(val->result_ok);
3799         LDKQueryShortChannelIds res_var = (*val->contents.result);
3800         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3801         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3802         long res_ref = (long)res_var.inner & ~1;
3803         return res_ref;
3804 }
3805 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
3806         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3807         CHECK(!val->result_ok);
3808         LDKDecodeError err_var = (*val->contents.err);
3809         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3810         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3811         long err_ref = (long)err_var.inner & ~1;
3812         return err_ref;
3813 }
3814 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
3815         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3816 }
3817 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
3818         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3819         CHECK(val->result_ok);
3820         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
3821         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3822         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3823         long res_ref = (long)res_var.inner & ~1;
3824         return res_ref;
3825 }
3826 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
3827         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3828         CHECK(!val->result_ok);
3829         LDKDecodeError err_var = (*val->contents.err);
3830         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3831         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3832         long err_ref = (long)err_var.inner & ~1;
3833         return err_ref;
3834 }
3835 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3836         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3837 }
3838 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3839         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3840         CHECK(val->result_ok);
3841         LDKQueryChannelRange res_var = (*val->contents.result);
3842         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3843         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3844         long res_ref = (long)res_var.inner & ~1;
3845         return res_ref;
3846 }
3847 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3848         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3849         CHECK(!val->result_ok);
3850         LDKDecodeError err_var = (*val->contents.err);
3851         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3852         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3853         long err_ref = (long)err_var.inner & ~1;
3854         return err_ref;
3855 }
3856 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3857         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3858 }
3859 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3860         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3861         CHECK(val->result_ok);
3862         LDKReplyChannelRange res_var = (*val->contents.result);
3863         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3864         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3865         long res_ref = (long)res_var.inner & ~1;
3866         return res_ref;
3867 }
3868 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3869         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3870         CHECK(!val->result_ok);
3871         LDKDecodeError err_var = (*val->contents.err);
3872         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3873         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3874         long err_ref = (long)err_var.inner & ~1;
3875         return err_ref;
3876 }
3877 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
3878         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3879 }
3880 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
3881         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3882         CHECK(val->result_ok);
3883         LDKGossipTimestampFilter res_var = (*val->contents.result);
3884         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3885         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3886         long res_ref = (long)res_var.inner & ~1;
3887         return res_ref;
3888 }
3889 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
3890         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3891         CHECK(!val->result_ok);
3892         LDKDecodeError err_var = (*val->contents.err);
3893         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3894         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3895         long err_ref = (long)err_var.inner & ~1;
3896         return err_ref;
3897 }
3898 typedef struct LDKMessageSendEventsProvider_JCalls {
3899         atomic_size_t refcnt;
3900         uint32_t get_and_clear_pending_msg_events_meth;
3901 } LDKMessageSendEventsProvider_JCalls;
3902 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
3903         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3904         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3905                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
3906                 FREE(j_calls);
3907         }
3908 }
3909 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
3910         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3911         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
3912         LDKCVec_MessageSendEventZ ret_constr;
3913         ret_constr.datalen = *((uint32_t*)ret);
3914         if (ret_constr.datalen > 0)
3915                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3916         else
3917                 ret_constr.data = NULL;
3918         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3919         for (size_t s = 0; s < ret_constr.datalen; s++) {
3920                 uint32_t ret_conv_18 = ret_vals[s];
3921                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
3922                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
3923                 ret_constr.data[s] = ret_conv_18_conv;
3924         }
3925         return ret_constr;
3926 }
3927 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
3928         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3929         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3930         return (void*) this_arg;
3931 }
3932 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3933         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
3934         atomic_init(&calls->refcnt, 1);
3935         //TODO: Assign calls->o from o
3936
3937         LDKMessageSendEventsProvider ret = {
3938                 .this_arg = (void*) calls,
3939                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
3940                 .free = LDKMessageSendEventsProvider_JCalls_free,
3941         };
3942         return ret;
3943 }
3944 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3945         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
3946         *res_ptr = LDKMessageSendEventsProvider_init(o);
3947         return (long)res_ptr;
3948 }
3949 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
3950         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
3951         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
3952         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3953         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3954         for (size_t s = 0; s < ret_var.datalen; s++) {
3955                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
3956                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
3957                 long ret_conv_18_ref = (long)ret_conv_18_copy;
3958                 ret_arr_ptr[s] = ret_conv_18_ref;
3959         }
3960         FREE(ret_var.data);
3961         return ret_arr;
3962 }
3963
3964 typedef struct LDKEventsProvider_JCalls {
3965         atomic_size_t refcnt;
3966         uint32_t get_and_clear_pending_events_meth;
3967 } LDKEventsProvider_JCalls;
3968 static void LDKEventsProvider_JCalls_free(void* this_arg) {
3969         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3970         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3971                 js_free(j_calls->get_and_clear_pending_events_meth);
3972                 FREE(j_calls);
3973         }
3974 }
3975 LDKCVec_EventZ get_and_clear_pending_events_LDKEventsProvider_jcall(const void* this_arg) {
3976         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3977         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
3978         LDKCVec_EventZ ret_constr;
3979         ret_constr.datalen = *((uint32_t*)ret);
3980         if (ret_constr.datalen > 0)
3981                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3982         else
3983                 ret_constr.data = NULL;
3984         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3985         for (size_t h = 0; h < ret_constr.datalen; h++) {
3986                 uint32_t ret_conv_7 = ret_vals[h];
3987                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
3988                 ret_conv_7_conv = Event_clone((LDKEvent*)(((uint64_t)ret_conv_7) & ~1));
3989                 ret_constr.data[h] = ret_conv_7_conv;
3990         }
3991         return ret_constr;
3992 }
3993 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
3994         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3995         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3996         return (void*) this_arg;
3997 }
3998 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3999         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4000         atomic_init(&calls->refcnt, 1);
4001         //TODO: Assign calls->o from o
4002
4003         LDKEventsProvider ret = {
4004                 .this_arg = (void*) calls,
4005                 .get_and_clear_pending_events = get_and_clear_pending_events_LDKEventsProvider_jcall,
4006                 .free = LDKEventsProvider_JCalls_free,
4007         };
4008         return ret;
4009 }
4010 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4011         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4012         *res_ptr = LDKEventsProvider_init(o);
4013         return (long)res_ptr;
4014 }
4015 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
4016         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4017         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4018         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4019         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4020         for (size_t h = 0; h < ret_var.datalen; h++) {
4021                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4022                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
4023                 long ret_conv_7_ref = (long)ret_conv_7_copy;
4024                 ret_arr_ptr[h] = ret_conv_7_ref;
4025         }
4026         FREE(ret_var.data);
4027         return ret_arr;
4028 }
4029
4030 typedef struct LDKAccess_JCalls {
4031         atomic_size_t refcnt;
4032         uint32_t get_utxo_meth;
4033 } LDKAccess_JCalls;
4034 static void LDKAccess_JCalls_free(void* this_arg) {
4035         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4036         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4037                 js_free(j_calls->get_utxo_meth);
4038                 FREE(j_calls);
4039         }
4040 }
4041 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4042         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4043         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4044         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4045         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4046         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4047         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4048         return ret_conv;
4049 }
4050 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4051         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4052         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4053         return (void*) this_arg;
4054 }
4055 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4056         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4057         atomic_init(&calls->refcnt, 1);
4058         //TODO: Assign calls->o from o
4059
4060         LDKAccess ret = {
4061                 .this_arg = (void*) calls,
4062                 .get_utxo = get_utxo_LDKAccess_jcall,
4063                 .free = LDKAccess_JCalls_free,
4064         };
4065         return ret;
4066 }
4067 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4068         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4069         *res_ptr = LDKAccess_init(o);
4070         return (long)res_ptr;
4071 }
4072 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4073         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4074         unsigned char genesis_hash_arr[32];
4075         CHECK(*((uint32_t*)genesis_hash) == 32);
4076         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4077         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4078         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4079         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4080         return (long)ret_conv;
4081 }
4082
4083 typedef struct LDKListen_JCalls {
4084         atomic_size_t refcnt;
4085         uint32_t block_connected_meth;
4086         uint32_t block_disconnected_meth;
4087 } LDKListen_JCalls;
4088 static void LDKListen_JCalls_free(void* this_arg) {
4089         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4090         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4091                 js_free(j_calls->block_connected_meth);
4092                 js_free(j_calls->block_disconnected_meth);
4093                 FREE(j_calls);
4094         }
4095 }
4096 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4097         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4098         LDKu8slice block_var = block;
4099         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4100         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4101         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4102 }
4103 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4104         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4105         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4106         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4107         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4108 }
4109 static void* LDKListen_JCalls_clone(const void* this_arg) {
4110         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4111         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4112         return (void*) this_arg;
4113 }
4114 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4115         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4116         atomic_init(&calls->refcnt, 1);
4117         //TODO: Assign calls->o from o
4118
4119         LDKListen ret = {
4120                 .this_arg = (void*) calls,
4121                 .block_connected = block_connected_LDKListen_jcall,
4122                 .block_disconnected = block_disconnected_LDKListen_jcall,
4123                 .free = LDKListen_JCalls_free,
4124         };
4125         return ret;
4126 }
4127 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4128         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4129         *res_ptr = LDKListen_init(o);
4130         return (long)res_ptr;
4131 }
4132 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4133         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4134         LDKu8slice block_ref;
4135         block_ref.datalen = *((uint32_t*)block);
4136         block_ref.data = (int8_t*)(block + 4);
4137         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4138 }
4139
4140 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4141         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4142         unsigned char header_arr[80];
4143         CHECK(*((uint32_t*)header) == 80);
4144         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4145         unsigned char (*header_ref)[80] = &header_arr;
4146         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4147 }
4148
4149 typedef struct LDKFilter_JCalls {
4150         atomic_size_t refcnt;
4151         uint32_t register_tx_meth;
4152         uint32_t register_output_meth;
4153 } LDKFilter_JCalls;
4154 static void LDKFilter_JCalls_free(void* this_arg) {
4155         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4156         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4157                 js_free(j_calls->register_tx_meth);
4158                 js_free(j_calls->register_output_meth);
4159                 FREE(j_calls);
4160         }
4161 }
4162 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4163         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4164         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4165         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4166         LDKu8slice script_pubkey_var = script_pubkey;
4167         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4168         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4169         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4170 }
4171 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
4172         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4173         LDKWatchedOutput output_var = output;
4174         CHECK((((long)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4175         CHECK((((long)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4176         long output_ref = (long)output_var.inner;
4177         if (output_var.is_owned) {
4178                 output_ref |= 1;
4179         }
4180         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
4181         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
4182         // Warning: we may need a move here but no clone is available for LDKCOption_C2Tuple_usizeTransactionZZ
4183         return ret_conv;
4184 }
4185 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4186         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4187         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4188         return (void*) this_arg;
4189 }
4190 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
4191         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4192         atomic_init(&calls->refcnt, 1);
4193         //TODO: Assign calls->o from o
4194
4195         LDKFilter ret = {
4196                 .this_arg = (void*) calls,
4197                 .register_tx = register_tx_LDKFilter_jcall,
4198                 .register_output = register_output_LDKFilter_jcall,
4199                 .free = LDKFilter_JCalls_free,
4200         };
4201         return ret;
4202 }
4203 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
4204         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4205         *res_ptr = LDKFilter_init(o);
4206         return (long)res_ptr;
4207 }
4208 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
4209         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4210         unsigned char txid_arr[32];
4211         CHECK(*((uint32_t*)txid) == 32);
4212         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
4213         unsigned char (*txid_ref)[32] = &txid_arr;
4214         LDKu8slice script_pubkey_ref;
4215         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4216         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4217         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4218 }
4219
4220 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
4221         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4222         LDKWatchedOutput output_conv;
4223         output_conv.inner = (void*)(output & (~1));
4224         output_conv.is_owned = (output & 1) || (output == 0);
4225         // Warning: we need a move here but no clone is available for LDKWatchedOutput
4226         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
4227         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
4228         long ret_ref = (long)ret_copy;
4229         return ret_ref;
4230 }
4231
4232 typedef struct LDKPersist_JCalls {
4233         atomic_size_t refcnt;
4234         uint32_t persist_new_channel_meth;
4235         uint32_t update_persisted_channel_meth;
4236 } LDKPersist_JCalls;
4237 static void LDKPersist_JCalls_free(void* this_arg) {
4238         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4239         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4240                 js_free(j_calls->persist_new_channel_meth);
4241                 js_free(j_calls->update_persisted_channel_meth);
4242                 FREE(j_calls);
4243         }
4244 }
4245 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4246         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4247         LDKOutPoint id_var = id;
4248         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4249         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4250         long id_ref = (long)id_var.inner;
4251         if (id_var.is_owned) {
4252                 id_ref |= 1;
4253         }
4254         LDKChannelMonitor data_var = *data;
4255         data_var = ChannelMonitor_clone(data);
4256         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4257         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4258         long data_ref = (long)data_var.inner;
4259         if (data_var.is_owned) {
4260                 data_ref |= 1;
4261         }
4262         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
4263         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4264         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4265         return ret_conv;
4266 }
4267 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
4268         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4269         LDKOutPoint id_var = id;
4270         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4271         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4272         long id_ref = (long)id_var.inner;
4273         if (id_var.is_owned) {
4274                 id_ref |= 1;
4275         }
4276         LDKChannelMonitorUpdate update_var = *update;
4277         update_var = ChannelMonitorUpdate_clone(update);
4278         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4279         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4280         long update_ref = (long)update_var.inner;
4281         if (update_var.is_owned) {
4282                 update_ref |= 1;
4283         }
4284         LDKChannelMonitor data_var = *data;
4285         data_var = ChannelMonitor_clone(data);
4286         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4287         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4288         long data_ref = (long)data_var.inner;
4289         if (data_var.is_owned) {
4290                 data_ref |= 1;
4291         }
4292         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
4293         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4294         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4295         return ret_conv;
4296 }
4297 static void* LDKPersist_JCalls_clone(const void* this_arg) {
4298         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4299         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4300         return (void*) this_arg;
4301 }
4302 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
4303         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
4304         atomic_init(&calls->refcnt, 1);
4305         //TODO: Assign calls->o from o
4306
4307         LDKPersist ret = {
4308                 .this_arg = (void*) calls,
4309                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
4310                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
4311                 .free = LDKPersist_JCalls_free,
4312         };
4313         return ret;
4314 }
4315 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
4316         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
4317         *res_ptr = LDKPersist_init(o);
4318         return (long)res_ptr;
4319 }
4320 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
4321         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4322         LDKOutPoint id_conv;
4323         id_conv.inner = (void*)(id & (~1));
4324         id_conv.is_owned = (id & 1) || (id == 0);
4325         id_conv = OutPoint_clone(&id_conv);
4326         LDKChannelMonitor data_conv;
4327         data_conv.inner = (void*)(data & (~1));
4328         data_conv.is_owned = false;
4329         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4330         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
4331         return (long)ret_conv;
4332 }
4333
4334 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
4335         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4336         LDKOutPoint id_conv;
4337         id_conv.inner = (void*)(id & (~1));
4338         id_conv.is_owned = (id & 1) || (id == 0);
4339         id_conv = OutPoint_clone(&id_conv);
4340         LDKChannelMonitorUpdate update_conv;
4341         update_conv.inner = (void*)(update & (~1));
4342         update_conv.is_owned = false;
4343         LDKChannelMonitor data_conv;
4344         data_conv.inner = (void*)(data & (~1));
4345         data_conv.is_owned = false;
4346         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4347         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
4348         return (long)ret_conv;
4349 }
4350
4351 typedef struct LDKChannelMessageHandler_JCalls {
4352         atomic_size_t refcnt;
4353         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4354         uint32_t handle_open_channel_meth;
4355         uint32_t handle_accept_channel_meth;
4356         uint32_t handle_funding_created_meth;
4357         uint32_t handle_funding_signed_meth;
4358         uint32_t handle_funding_locked_meth;
4359         uint32_t handle_shutdown_meth;
4360         uint32_t handle_closing_signed_meth;
4361         uint32_t handle_update_add_htlc_meth;
4362         uint32_t handle_update_fulfill_htlc_meth;
4363         uint32_t handle_update_fail_htlc_meth;
4364         uint32_t handle_update_fail_malformed_htlc_meth;
4365         uint32_t handle_commitment_signed_meth;
4366         uint32_t handle_revoke_and_ack_meth;
4367         uint32_t handle_update_fee_meth;
4368         uint32_t handle_announcement_signatures_meth;
4369         uint32_t peer_disconnected_meth;
4370         uint32_t peer_connected_meth;
4371         uint32_t handle_channel_reestablish_meth;
4372         uint32_t handle_channel_update_meth;
4373         uint32_t handle_error_meth;
4374 } LDKChannelMessageHandler_JCalls;
4375 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
4376         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4378                 js_free(j_calls->handle_open_channel_meth);
4379                 js_free(j_calls->handle_accept_channel_meth);
4380                 js_free(j_calls->handle_funding_created_meth);
4381                 js_free(j_calls->handle_funding_signed_meth);
4382                 js_free(j_calls->handle_funding_locked_meth);
4383                 js_free(j_calls->handle_shutdown_meth);
4384                 js_free(j_calls->handle_closing_signed_meth);
4385                 js_free(j_calls->handle_update_add_htlc_meth);
4386                 js_free(j_calls->handle_update_fulfill_htlc_meth);
4387                 js_free(j_calls->handle_update_fail_htlc_meth);
4388                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
4389                 js_free(j_calls->handle_commitment_signed_meth);
4390                 js_free(j_calls->handle_revoke_and_ack_meth);
4391                 js_free(j_calls->handle_update_fee_meth);
4392                 js_free(j_calls->handle_announcement_signatures_meth);
4393                 js_free(j_calls->peer_disconnected_meth);
4394                 js_free(j_calls->peer_connected_meth);
4395                 js_free(j_calls->handle_channel_reestablish_meth);
4396                 js_free(j_calls->handle_channel_update_meth);
4397                 js_free(j_calls->handle_error_meth);
4398                 FREE(j_calls);
4399         }
4400 }
4401 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
4402         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4403         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4404         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4405         LDKInitFeatures their_features_var = their_features;
4406         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4407         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4408         long their_features_ref = (long)their_features_var.inner;
4409         if (their_features_var.is_owned) {
4410                 their_features_ref |= 1;
4411         }
4412         LDKOpenChannel msg_var = *msg;
4413         msg_var = OpenChannel_clone(msg);
4414         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4415         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4416         long msg_ref = (long)msg_var.inner;
4417         if (msg_var.is_owned) {
4418                 msg_ref |= 1;
4419         }
4420         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4421 }
4422 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
4423         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4424         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4425         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4426         LDKInitFeatures their_features_var = their_features;
4427         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4428         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4429         long their_features_ref = (long)their_features_var.inner;
4430         if (their_features_var.is_owned) {
4431                 their_features_ref |= 1;
4432         }
4433         LDKAcceptChannel msg_var = *msg;
4434         msg_var = AcceptChannel_clone(msg);
4435         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4436         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4437         long msg_ref = (long)msg_var.inner;
4438         if (msg_var.is_owned) {
4439                 msg_ref |= 1;
4440         }
4441         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4442 }
4443 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
4444         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4445         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4446         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4447         LDKFundingCreated msg_var = *msg;
4448         msg_var = FundingCreated_clone(msg);
4449         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4450         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4451         long msg_ref = (long)msg_var.inner;
4452         if (msg_var.is_owned) {
4453                 msg_ref |= 1;
4454         }
4455         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
4456 }
4457 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
4458         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4459         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4460         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4461         LDKFundingSigned msg_var = *msg;
4462         msg_var = FundingSigned_clone(msg);
4463         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         long msg_ref = (long)msg_var.inner;
4466         if (msg_var.is_owned) {
4467                 msg_ref |= 1;
4468         }
4469         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
4470 }
4471 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
4472         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4473         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4474         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4475         LDKFundingLocked msg_var = *msg;
4476         msg_var = FundingLocked_clone(msg);
4477         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4478         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4479         long msg_ref = (long)msg_var.inner;
4480         if (msg_var.is_owned) {
4481                 msg_ref |= 1;
4482         }
4483         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
4484 }
4485 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
4486         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4487         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4488         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4489         LDKInitFeatures their_features_var = *their_features;
4490         their_features_var = InitFeatures_clone(their_features);
4491         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4492         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4493         long their_features_ref = (long)their_features_var.inner;
4494         if (their_features_var.is_owned) {
4495                 their_features_ref |= 1;
4496         }
4497         LDKShutdown msg_var = *msg;
4498         msg_var = Shutdown_clone(msg);
4499         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4500         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4501         long msg_ref = (long)msg_var.inner;
4502         if (msg_var.is_owned) {
4503                 msg_ref |= 1;
4504         }
4505         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
4506 }
4507 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
4508         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4509         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4510         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4511         LDKClosingSigned msg_var = *msg;
4512         msg_var = ClosingSigned_clone(msg);
4513         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4514         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4515         long msg_ref = (long)msg_var.inner;
4516         if (msg_var.is_owned) {
4517                 msg_ref |= 1;
4518         }
4519         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
4520 }
4521 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
4522         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4523         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4524         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4525         LDKUpdateAddHTLC msg_var = *msg;
4526         msg_var = UpdateAddHTLC_clone(msg);
4527         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4528         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4529         long msg_ref = (long)msg_var.inner;
4530         if (msg_var.is_owned) {
4531                 msg_ref |= 1;
4532         }
4533         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
4534 }
4535 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
4536         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4537         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4538         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4539         LDKUpdateFulfillHTLC msg_var = *msg;
4540         msg_var = UpdateFulfillHTLC_clone(msg);
4541         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4542         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4543         long msg_ref = (long)msg_var.inner;
4544         if (msg_var.is_owned) {
4545                 msg_ref |= 1;
4546         }
4547         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
4548 }
4549 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
4550         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4551         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4552         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4553         LDKUpdateFailHTLC msg_var = *msg;
4554         msg_var = UpdateFailHTLC_clone(msg);
4555         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4556         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4557         long msg_ref = (long)msg_var.inner;
4558         if (msg_var.is_owned) {
4559                 msg_ref |= 1;
4560         }
4561         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
4562 }
4563 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
4564         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4565         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4566         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4567         LDKUpdateFailMalformedHTLC msg_var = *msg;
4568         msg_var = UpdateFailMalformedHTLC_clone(msg);
4569         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4570         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4571         long msg_ref = (long)msg_var.inner;
4572         if (msg_var.is_owned) {
4573                 msg_ref |= 1;
4574         }
4575         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
4576 }
4577 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
4578         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4579         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4580         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4581         LDKCommitmentSigned msg_var = *msg;
4582         msg_var = CommitmentSigned_clone(msg);
4583         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4584         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4585         long msg_ref = (long)msg_var.inner;
4586         if (msg_var.is_owned) {
4587                 msg_ref |= 1;
4588         }
4589         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
4590 }
4591 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
4592         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4593         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4594         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4595         LDKRevokeAndACK msg_var = *msg;
4596         msg_var = RevokeAndACK_clone(msg);
4597         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4598         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4599         long msg_ref = (long)msg_var.inner;
4600         if (msg_var.is_owned) {
4601                 msg_ref |= 1;
4602         }
4603         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
4604 }
4605 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
4606         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4607         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4608         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4609         LDKUpdateFee msg_var = *msg;
4610         msg_var = UpdateFee_clone(msg);
4611         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4612         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4613         long msg_ref = (long)msg_var.inner;
4614         if (msg_var.is_owned) {
4615                 msg_ref |= 1;
4616         }
4617         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
4618 }
4619 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
4620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4621         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4622         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4623         LDKAnnouncementSignatures msg_var = *msg;
4624         msg_var = AnnouncementSignatures_clone(msg);
4625         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4626         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4627         long msg_ref = (long)msg_var.inner;
4628         if (msg_var.is_owned) {
4629                 msg_ref |= 1;
4630         }
4631         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
4632 }
4633 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
4634         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4635         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4636         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4637         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
4638 }
4639 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
4640         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4641         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4642         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4643         LDKInit msg_var = *msg;
4644         msg_var = Init_clone(msg);
4645         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4646         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4647         long msg_ref = (long)msg_var.inner;
4648         if (msg_var.is_owned) {
4649                 msg_ref |= 1;
4650         }
4651         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
4652 }
4653 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
4654         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4655         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4656         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4657         LDKChannelReestablish msg_var = *msg;
4658         msg_var = ChannelReestablish_clone(msg);
4659         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4660         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4661         long msg_ref = (long)msg_var.inner;
4662         if (msg_var.is_owned) {
4663                 msg_ref |= 1;
4664         }
4665         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
4666 }
4667 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
4668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4669         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4670         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4671         LDKChannelUpdate msg_var = *msg;
4672         msg_var = ChannelUpdate_clone(msg);
4673         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4674         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4675         long msg_ref = (long)msg_var.inner;
4676         if (msg_var.is_owned) {
4677                 msg_ref |= 1;
4678         }
4679         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
4680 }
4681 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
4682         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4683         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4684         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4685         LDKErrorMessage msg_var = *msg;
4686         msg_var = ErrorMessage_clone(msg);
4687         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4688         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4689         long msg_ref = (long)msg_var.inner;
4690         if (msg_var.is_owned) {
4691                 msg_ref |= 1;
4692         }
4693         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
4694 }
4695 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
4696         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4697         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4698         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4699         return (void*) this_arg;
4700 }
4701 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4702         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
4703         atomic_init(&calls->refcnt, 1);
4704         //TODO: Assign calls->o from o
4705
4706         LDKChannelMessageHandler ret = {
4707                 .this_arg = (void*) calls,
4708                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
4709                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
4710                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
4711                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
4712                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
4713                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
4714                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
4715                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
4716                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
4717                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
4718                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
4719                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
4720                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
4721                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
4722                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
4723                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
4724                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
4725                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
4726                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
4727                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
4728                 .free = LDKChannelMessageHandler_JCalls_free,
4729                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4730         };
4731         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4732         return ret;
4733 }
4734 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4735         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
4736         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
4737         return (long)res_ptr;
4738 }
4739 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4740         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4741         LDKPublicKey their_node_id_ref;
4742         CHECK(*((uint32_t*)their_node_id) == 33);
4743         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4744         LDKInitFeatures their_features_conv;
4745         their_features_conv.inner = (void*)(their_features & (~1));
4746         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4747         their_features_conv = InitFeatures_clone(&their_features_conv);
4748         LDKOpenChannel msg_conv;
4749         msg_conv.inner = (void*)(msg & (~1));
4750         msg_conv.is_owned = false;
4751         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4752 }
4753
4754 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4755         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4756         LDKPublicKey their_node_id_ref;
4757         CHECK(*((uint32_t*)their_node_id) == 33);
4758         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4759         LDKInitFeatures their_features_conv;
4760         their_features_conv.inner = (void*)(their_features & (~1));
4761         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4762         their_features_conv = InitFeatures_clone(&their_features_conv);
4763         LDKAcceptChannel msg_conv;
4764         msg_conv.inner = (void*)(msg & (~1));
4765         msg_conv.is_owned = false;
4766         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4767 }
4768
4769 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4770         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4771         LDKPublicKey their_node_id_ref;
4772         CHECK(*((uint32_t*)their_node_id) == 33);
4773         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4774         LDKFundingCreated msg_conv;
4775         msg_conv.inner = (void*)(msg & (~1));
4776         msg_conv.is_owned = false;
4777         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4778 }
4779
4780 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4781         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4782         LDKPublicKey their_node_id_ref;
4783         CHECK(*((uint32_t*)their_node_id) == 33);
4784         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4785         LDKFundingSigned msg_conv;
4786         msg_conv.inner = (void*)(msg & (~1));
4787         msg_conv.is_owned = false;
4788         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4789 }
4790
4791 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4792         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4793         LDKPublicKey their_node_id_ref;
4794         CHECK(*((uint32_t*)their_node_id) == 33);
4795         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4796         LDKFundingLocked msg_conv;
4797         msg_conv.inner = (void*)(msg & (~1));
4798         msg_conv.is_owned = false;
4799         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4800 }
4801
4802 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4803         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4804         LDKPublicKey their_node_id_ref;
4805         CHECK(*((uint32_t*)their_node_id) == 33);
4806         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4807         LDKInitFeatures their_features_conv;
4808         their_features_conv.inner = (void*)(their_features & (~1));
4809         their_features_conv.is_owned = false;
4810         LDKShutdown msg_conv;
4811         msg_conv.inner = (void*)(msg & (~1));
4812         msg_conv.is_owned = false;
4813         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
4814 }
4815
4816 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4817         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4818         LDKPublicKey their_node_id_ref;
4819         CHECK(*((uint32_t*)their_node_id) == 33);
4820         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4821         LDKClosingSigned msg_conv;
4822         msg_conv.inner = (void*)(msg & (~1));
4823         msg_conv.is_owned = false;
4824         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4825 }
4826
4827 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4828         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4829         LDKPublicKey their_node_id_ref;
4830         CHECK(*((uint32_t*)their_node_id) == 33);
4831         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4832         LDKUpdateAddHTLC msg_conv;
4833         msg_conv.inner = (void*)(msg & (~1));
4834         msg_conv.is_owned = false;
4835         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4836 }
4837
4838 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4839         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4840         LDKPublicKey their_node_id_ref;
4841         CHECK(*((uint32_t*)their_node_id) == 33);
4842         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4843         LDKUpdateFulfillHTLC msg_conv;
4844         msg_conv.inner = (void*)(msg & (~1));
4845         msg_conv.is_owned = false;
4846         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4847 }
4848
4849 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4850         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4851         LDKPublicKey their_node_id_ref;
4852         CHECK(*((uint32_t*)their_node_id) == 33);
4853         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4854         LDKUpdateFailHTLC msg_conv;
4855         msg_conv.inner = (void*)(msg & (~1));
4856         msg_conv.is_owned = false;
4857         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4858 }
4859
4860 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4861         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4862         LDKPublicKey their_node_id_ref;
4863         CHECK(*((uint32_t*)their_node_id) == 33);
4864         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4865         LDKUpdateFailMalformedHTLC msg_conv;
4866         msg_conv.inner = (void*)(msg & (~1));
4867         msg_conv.is_owned = false;
4868         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4869 }
4870
4871 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4872         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4873         LDKPublicKey their_node_id_ref;
4874         CHECK(*((uint32_t*)their_node_id) == 33);
4875         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4876         LDKCommitmentSigned msg_conv;
4877         msg_conv.inner = (void*)(msg & (~1));
4878         msg_conv.is_owned = false;
4879         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4880 }
4881
4882 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4883         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4884         LDKPublicKey their_node_id_ref;
4885         CHECK(*((uint32_t*)their_node_id) == 33);
4886         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4887         LDKRevokeAndACK msg_conv;
4888         msg_conv.inner = (void*)(msg & (~1));
4889         msg_conv.is_owned = false;
4890         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4891 }
4892
4893 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4894         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4895         LDKPublicKey their_node_id_ref;
4896         CHECK(*((uint32_t*)their_node_id) == 33);
4897         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4898         LDKUpdateFee msg_conv;
4899         msg_conv.inner = (void*)(msg & (~1));
4900         msg_conv.is_owned = false;
4901         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4902 }
4903
4904 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4905         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4906         LDKPublicKey their_node_id_ref;
4907         CHECK(*((uint32_t*)their_node_id) == 33);
4908         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4909         LDKAnnouncementSignatures msg_conv;
4910         msg_conv.inner = (void*)(msg & (~1));
4911         msg_conv.is_owned = false;
4912         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4913 }
4914
4915 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
4916         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4917         LDKPublicKey their_node_id_ref;
4918         CHECK(*((uint32_t*)their_node_id) == 33);
4919         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4920         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
4921 }
4922
4923 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4924         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4925         LDKPublicKey their_node_id_ref;
4926         CHECK(*((uint32_t*)their_node_id) == 33);
4927         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4928         LDKInit msg_conv;
4929         msg_conv.inner = (void*)(msg & (~1));
4930         msg_conv.is_owned = false;
4931         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4932 }
4933
4934 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4935         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4936         LDKPublicKey their_node_id_ref;
4937         CHECK(*((uint32_t*)their_node_id) == 33);
4938         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4939         LDKChannelReestablish msg_conv;
4940         msg_conv.inner = (void*)(msg & (~1));
4941         msg_conv.is_owned = false;
4942         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4943 }
4944
4945 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4946         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4947         LDKPublicKey their_node_id_ref;
4948         CHECK(*((uint32_t*)their_node_id) == 33);
4949         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4950         LDKChannelUpdate msg_conv;
4951         msg_conv.inner = (void*)(msg & (~1));
4952         msg_conv.is_owned = false;
4953         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4954 }
4955
4956 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4957         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4958         LDKPublicKey their_node_id_ref;
4959         CHECK(*((uint32_t*)their_node_id) == 33);
4960         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4961         LDKErrorMessage msg_conv;
4962         msg_conv.inner = (void*)(msg & (~1));
4963         msg_conv.is_owned = false;
4964         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4965 }
4966
4967 typedef struct LDKRoutingMessageHandler_JCalls {
4968         atomic_size_t refcnt;
4969         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4970         uint32_t handle_node_announcement_meth;
4971         uint32_t handle_channel_announcement_meth;
4972         uint32_t handle_channel_update_meth;
4973         uint32_t handle_htlc_fail_channel_update_meth;
4974         uint32_t get_next_channel_announcements_meth;
4975         uint32_t get_next_node_announcements_meth;
4976         uint32_t sync_routing_table_meth;
4977         uint32_t handle_reply_channel_range_meth;
4978         uint32_t handle_reply_short_channel_ids_end_meth;
4979         uint32_t handle_query_channel_range_meth;
4980         uint32_t handle_query_short_channel_ids_meth;
4981 } LDKRoutingMessageHandler_JCalls;
4982 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
4983         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4984         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4985                 js_free(j_calls->handle_node_announcement_meth);
4986                 js_free(j_calls->handle_channel_announcement_meth);
4987                 js_free(j_calls->handle_channel_update_meth);
4988                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
4989                 js_free(j_calls->get_next_channel_announcements_meth);
4990                 js_free(j_calls->get_next_node_announcements_meth);
4991                 js_free(j_calls->sync_routing_table_meth);
4992                 js_free(j_calls->handle_reply_channel_range_meth);
4993                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
4994                 js_free(j_calls->handle_query_channel_range_meth);
4995                 js_free(j_calls->handle_query_short_channel_ids_meth);
4996                 FREE(j_calls);
4997         }
4998 }
4999 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5000         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5001         LDKNodeAnnouncement msg_var = *msg;
5002         msg_var = NodeAnnouncement_clone(msg);
5003         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5004         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5005         long msg_ref = (long)msg_var.inner;
5006         if (msg_var.is_owned) {
5007                 msg_ref |= 1;
5008         }
5009         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5010         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5011         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5012         return ret_conv;
5013 }
5014 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5016         LDKChannelAnnouncement msg_var = *msg;
5017         msg_var = ChannelAnnouncement_clone(msg);
5018         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5019         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5020         long msg_ref = (long)msg_var.inner;
5021         if (msg_var.is_owned) {
5022                 msg_ref |= 1;
5023         }
5024         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5025         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5026         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5027         return ret_conv;
5028 }
5029 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5030         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5031         LDKChannelUpdate msg_var = *msg;
5032         msg_var = ChannelUpdate_clone(msg);
5033         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5034         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5035         long msg_ref = (long)msg_var.inner;
5036         if (msg_var.is_owned) {
5037                 msg_ref |= 1;
5038         }
5039         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5040         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5041         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5042         return ret_conv;
5043 }
5044 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5045         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5046         long ret_update = (long)update;
5047         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5048 }
5049 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5050         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5051         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5052         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5053         ret_constr.datalen = *((uint32_t*)ret);
5054         if (ret_constr.datalen > 0)
5055                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5056         else
5057                 ret_constr.data = NULL;
5058         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5059         for (size_t l = 0; l < ret_constr.datalen; l++) {
5060                 uint32_t ret_conv_63 = ret_vals[l];
5061                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5062                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5063                 ret_constr.data[l] = ret_conv_63_conv;
5064         }
5065         return ret_constr;
5066 }
5067 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5068         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5069         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5070         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5071         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5072         LDKCVec_NodeAnnouncementZ ret_constr;
5073         ret_constr.datalen = *((uint32_t*)ret);
5074         if (ret_constr.datalen > 0)
5075                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5076         else
5077                 ret_constr.data = NULL;
5078         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5079         for (size_t s = 0; s < ret_constr.datalen; s++) {
5080                 uint32_t ret_conv_18 = ret_vals[s];
5081                 LDKNodeAnnouncement ret_conv_18_conv;
5082                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5083                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5084                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5085                 ret_constr.data[s] = ret_conv_18_conv;
5086         }
5087         return ret_constr;
5088 }
5089 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5090         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5091         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5092         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5093         LDKInit init_var = *init;
5094         init_var = Init_clone(init);
5095         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5096         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5097         long init_ref = (long)init_var.inner;
5098         if (init_var.is_owned) {
5099                 init_ref |= 1;
5100         }
5101         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5102 }
5103 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5104         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5105         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5106         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5107         LDKReplyChannelRange msg_var = msg;
5108         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5109         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5110         long msg_ref = (long)msg_var.inner;
5111         if (msg_var.is_owned) {
5112                 msg_ref |= 1;
5113         }
5114         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
5115         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5116         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5117         return ret_conv;
5118 }
5119 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5120         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5121         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5122         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5123         LDKReplyShortChannelIdsEnd msg_var = msg;
5124         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5125         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5126         long msg_ref = (long)msg_var.inner;
5127         if (msg_var.is_owned) {
5128                 msg_ref |= 1;
5129         }
5130         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5131         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5132         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5133         return ret_conv;
5134 }
5135 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5136         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5137         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5138         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5139         LDKQueryChannelRange msg_var = msg;
5140         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5141         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5142         long msg_ref = (long)msg_var.inner;
5143         if (msg_var.is_owned) {
5144                 msg_ref |= 1;
5145         }
5146         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
5147         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5148         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5149         return ret_conv;
5150 }
5151 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
5152         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5153         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5154         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5155         LDKQueryShortChannelIds msg_var = msg;
5156         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5157         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5158         long msg_ref = (long)msg_var.inner;
5159         if (msg_var.is_owned) {
5160                 msg_ref |= 1;
5161         }
5162         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
5163         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5164         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5165         return ret_conv;
5166 }
5167 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
5168         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5169         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5170         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5171         return (void*) this_arg;
5172 }
5173 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5174         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
5175         atomic_init(&calls->refcnt, 1);
5176         //TODO: Assign calls->o from o
5177
5178         LDKRoutingMessageHandler ret = {
5179                 .this_arg = (void*) calls,
5180                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
5181                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
5182                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
5183                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
5184                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
5185                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
5186                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
5187                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
5188                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
5189                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
5190                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
5191                 .free = LDKRoutingMessageHandler_JCalls_free,
5192                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5193         };
5194         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5195         return ret;
5196 }
5197 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5198         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
5199         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
5200         return (long)res_ptr;
5201 }
5202 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
5203         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5204         LDKNodeAnnouncement msg_conv;
5205         msg_conv.inner = (void*)(msg & (~1));
5206         msg_conv.is_owned = false;
5207         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5208         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
5209         return (long)ret_conv;
5210 }
5211
5212 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
5213         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5214         LDKChannelAnnouncement msg_conv;
5215         msg_conv.inner = (void*)(msg & (~1));
5216         msg_conv.is_owned = false;
5217         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5218         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5219         return (long)ret_conv;
5220 }
5221
5222 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
5223         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5224         LDKChannelUpdate msg_conv;
5225         msg_conv.inner = (void*)(msg & (~1));
5226         msg_conv.is_owned = false;
5227         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5228         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
5229         return (long)ret_conv;
5230 }
5231
5232 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
5233         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5234         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
5235         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
5236 }
5237
5238 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
5239         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5240         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
5241         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5242         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5243         for (size_t l = 0; l < ret_var.datalen; l++) {
5244                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5245                 *ret_conv_63_ref = ret_var.data[l];
5246                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
5247         }
5248         FREE(ret_var.data);
5249         return ret_arr;
5250 }
5251
5252 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
5253         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5254         LDKPublicKey starting_point_ref;
5255         CHECK(*((uint32_t*)starting_point) == 33);
5256         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
5257         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
5258         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5259         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5260         for (size_t s = 0; s < ret_var.datalen; s++) {
5261                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
5262                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5263                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5264                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
5265                 if (ret_conv_18_var.is_owned) {
5266                         ret_conv_18_ref |= 1;
5267                 }
5268                 ret_arr_ptr[s] = ret_conv_18_ref;
5269         }
5270         FREE(ret_var.data);
5271         return ret_arr;
5272 }
5273
5274 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
5275         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5276         LDKPublicKey their_node_id_ref;
5277         CHECK(*((uint32_t*)their_node_id) == 33);
5278         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5279         LDKInit init_conv;
5280         init_conv.inner = (void*)(init & (~1));
5281         init_conv.is_owned = false;
5282         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
5283 }
5284
5285 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5286         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5287         LDKPublicKey their_node_id_ref;
5288         CHECK(*((uint32_t*)their_node_id) == 33);
5289         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5290         LDKReplyChannelRange msg_conv;
5291         msg_conv.inner = (void*)(msg & (~1));
5292         msg_conv.is_owned = (msg & 1) || (msg == 0);
5293         msg_conv = ReplyChannelRange_clone(&msg_conv);
5294         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5295         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5296         return (long)ret_conv;
5297 }
5298
5299 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5300         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5301         LDKPublicKey their_node_id_ref;
5302         CHECK(*((uint32_t*)their_node_id) == 33);
5303         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5304         LDKReplyShortChannelIdsEnd msg_conv;
5305         msg_conv.inner = (void*)(msg & (~1));
5306         msg_conv.is_owned = (msg & 1) || (msg == 0);
5307         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
5308         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5309         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5310         return (long)ret_conv;
5311 }
5312
5313 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5314         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5315         LDKPublicKey their_node_id_ref;
5316         CHECK(*((uint32_t*)their_node_id) == 33);
5317         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5318         LDKQueryChannelRange msg_conv;
5319         msg_conv.inner = (void*)(msg & (~1));
5320         msg_conv.is_owned = (msg & 1) || (msg == 0);
5321         msg_conv = QueryChannelRange_clone(&msg_conv);
5322         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5323         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5324         return (long)ret_conv;
5325 }
5326
5327 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5328         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5329         LDKPublicKey their_node_id_ref;
5330         CHECK(*((uint32_t*)their_node_id) == 33);
5331         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5332         LDKQueryShortChannelIds msg_conv;
5333         msg_conv.inner = (void*)(msg & (~1));
5334         msg_conv.is_owned = (msg & 1) || (msg == 0);
5335         msg_conv = QueryShortChannelIds_clone(&msg_conv);
5336         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5337         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5338         return (long)ret_conv;
5339 }
5340
5341 typedef struct LDKSocketDescriptor_JCalls {
5342         atomic_size_t refcnt;
5343         uint32_t send_data_meth;
5344         uint32_t disconnect_socket_meth;
5345         uint32_t eq_meth;
5346         uint32_t hash_meth;
5347 } LDKSocketDescriptor_JCalls;
5348 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
5349         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5350         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5351                 js_free(j_calls->send_data_meth);
5352                 js_free(j_calls->disconnect_socket_meth);
5353                 js_free(j_calls->eq_meth);
5354                 js_free(j_calls->hash_meth);
5355                 FREE(j_calls);
5356         }
5357 }
5358 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
5359         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5360         LDKu8slice data_var = data;
5361         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5362         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
5363         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
5364 }
5365 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
5366         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5367         js_invoke_function_0(j_calls->disconnect_socket_meth);
5368 }
5369 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
5370         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5371         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5372         *other_arg_clone = SocketDescriptor_clone(other_arg);
5373         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
5374 }
5375 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
5376         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5377         return js_invoke_function_0(j_calls->hash_meth);
5378 }
5379 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
5380         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5381         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5382         return (void*) this_arg;
5383 }
5384 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
5385         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
5386         atomic_init(&calls->refcnt, 1);
5387         //TODO: Assign calls->o from o
5388
5389         LDKSocketDescriptor ret = {
5390                 .this_arg = (void*) calls,
5391                 .send_data = send_data_LDKSocketDescriptor_jcall,
5392                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
5393                 .eq = eq_LDKSocketDescriptor_jcall,
5394                 .hash = hash_LDKSocketDescriptor_jcall,
5395                 .clone = LDKSocketDescriptor_JCalls_clone,
5396                 .free = LDKSocketDescriptor_JCalls_free,
5397         };
5398         return ret;
5399 }
5400 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
5401         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5402         *res_ptr = LDKSocketDescriptor_init(o);
5403         return (long)res_ptr;
5404 }
5405 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
5406         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5407         LDKu8slice data_ref;
5408         data_ref.datalen = *((uint32_t*)data);
5409         data_ref.data = (int8_t*)(data + 4);
5410         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
5411         return ret_val;
5412 }
5413
5414 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
5415         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5416         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
5417 }
5418
5419 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
5420         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5421         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
5422         return ret_val;
5423 }
5424
5425 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
5426         LDKTransaction _res_ref;
5427         _res_ref.datalen = *((uint32_t*)_res);
5428         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
5429         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5430         _res_ref.data_is_owned = true;
5431         Transaction_free(_res_ref);
5432 }
5433
5434 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
5435         if ((_res & 1) != 0) return;
5436         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
5437         FREE((void*)_res);
5438         TxOut_free(_res_conv);
5439 }
5440
5441 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
5442         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
5443         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5444         *ret_ref = TxOut_clone(orig_conv);
5445         return (long)ret_ref;
5446 }
5447
5448 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
5449         LDKSecretKey o_ref;
5450         CHECK(*((uint32_t*)o) == 32);
5451         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5452         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5453         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
5454         return (long)ret_conv;
5455 }
5456
5457 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
5458         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5459         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5460         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
5461         return (long)ret_conv;
5462 }
5463
5464 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
5465         if ((_res & 1) != 0) return;
5466         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
5467         FREE((void*)_res);
5468         CResult_SecretKeyErrorZ_free(_res_conv);
5469 }
5470
5471 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
5472         LDKPublicKey o_ref;
5473         CHECK(*((uint32_t*)o) == 33);
5474         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5475         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5476         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
5477         return (long)ret_conv;
5478 }
5479
5480 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
5481         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5482         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5483         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
5484         return (long)ret_conv;
5485 }
5486
5487 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
5488         if ((_res & 1) != 0) return;
5489         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
5490         FREE((void*)_res);
5491         CResult_PublicKeyErrorZ_free(_res_conv);
5492 }
5493
5494 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
5495         LDKTxCreationKeys o_conv;
5496         o_conv.inner = (void*)(o & (~1));
5497         o_conv.is_owned = (o & 1) || (o == 0);
5498         o_conv = TxCreationKeys_clone(&o_conv);
5499         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5500         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
5501         return (long)ret_conv;
5502 }
5503
5504 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
5505         LDKDecodeError e_conv;
5506         e_conv.inner = (void*)(e & (~1));
5507         e_conv.is_owned = (e & 1) || (e == 0);
5508         e_conv = DecodeError_clone(&e_conv);
5509         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5510         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
5511         return (long)ret_conv;
5512 }
5513
5514 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
5515         if ((_res & 1) != 0) return;
5516         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5517         FREE((void*)_res);
5518         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
5519 }
5520
5521 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
5522         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
5523         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5524         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
5525         return (long)ret_conv;
5526 }
5527
5528 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
5529         LDKChannelPublicKeys o_conv;
5530         o_conv.inner = (void*)(o & (~1));
5531         o_conv.is_owned = (o & 1) || (o == 0);
5532         o_conv = ChannelPublicKeys_clone(&o_conv);
5533         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5534         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
5535         return (long)ret_conv;
5536 }
5537
5538 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
5539         LDKDecodeError e_conv;
5540         e_conv.inner = (void*)(e & (~1));
5541         e_conv.is_owned = (e & 1) || (e == 0);
5542         e_conv = DecodeError_clone(&e_conv);
5543         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5544         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
5545         return (long)ret_conv;
5546 }
5547
5548 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
5549         if ((_res & 1) != 0) return;
5550         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5551         FREE((void*)_res);
5552         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
5553 }
5554
5555 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
5556         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
5557         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5558         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
5559         return (long)ret_conv;
5560 }
5561
5562 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
5563         LDKTxCreationKeys o_conv;
5564         o_conv.inner = (void*)(o & (~1));
5565         o_conv.is_owned = (o & 1) || (o == 0);
5566         o_conv = TxCreationKeys_clone(&o_conv);
5567         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5568         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
5569         return (long)ret_conv;
5570 }
5571
5572 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
5573         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5574         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5575         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
5576         return (long)ret_conv;
5577 }
5578
5579 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
5580         if ((_res & 1) != 0) return;
5581         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
5582         FREE((void*)_res);
5583         CResult_TxCreationKeysErrorZ_free(_res_conv);
5584 }
5585
5586 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
5587         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5588         *ret_copy = COption_u32Z_some(o);
5589         long ret_ref = (long)ret_copy;
5590         return ret_ref;
5591 }
5592
5593 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
5594         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5595         *ret_copy = COption_u32Z_none();
5596         long ret_ref = (long)ret_copy;
5597         return ret_ref;
5598 }
5599
5600 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
5601         if ((_res & 1) != 0) return;
5602         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
5603         FREE((void*)_res);
5604         COption_u32Z_free(_res_conv);
5605 }
5606
5607 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
5608         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
5609         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5610         *ret_copy = COption_u32Z_clone(orig_conv);
5611         long ret_ref = (long)ret_copy;
5612         return ret_ref;
5613 }
5614
5615 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
5616         LDKHTLCOutputInCommitment o_conv;
5617         o_conv.inner = (void*)(o & (~1));
5618         o_conv.is_owned = (o & 1) || (o == 0);
5619         o_conv = HTLCOutputInCommitment_clone(&o_conv);
5620         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5621         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
5622         return (long)ret_conv;
5623 }
5624
5625 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
5626         LDKDecodeError e_conv;
5627         e_conv.inner = (void*)(e & (~1));
5628         e_conv.is_owned = (e & 1) || (e == 0);
5629         e_conv = DecodeError_clone(&e_conv);
5630         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5631         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
5632         return (long)ret_conv;
5633 }
5634
5635 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
5636         if ((_res & 1) != 0) return;
5637         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
5638         FREE((void*)_res);
5639         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
5640 }
5641
5642 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
5643         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
5644         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5645         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
5646         return (long)ret_conv;
5647 }
5648
5649 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5650         LDKCounterpartyChannelTransactionParameters o_conv;
5651         o_conv.inner = (void*)(o & (~1));
5652         o_conv.is_owned = (o & 1) || (o == 0);
5653         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
5654         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5655         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5656         return (long)ret_conv;
5657 }
5658
5659 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5660         LDKDecodeError e_conv;
5661         e_conv.inner = (void*)(e & (~1));
5662         e_conv.is_owned = (e & 1) || (e == 0);
5663         e_conv = DecodeError_clone(&e_conv);
5664         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5665         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
5666         return (long)ret_conv;
5667 }
5668
5669 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5670         if ((_res & 1) != 0) return;
5671         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5672         FREE((void*)_res);
5673         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5674 }
5675
5676 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5677         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5678         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5679         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5680         return (long)ret_conv;
5681 }
5682
5683 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5684         LDKChannelTransactionParameters o_conv;
5685         o_conv.inner = (void*)(o & (~1));
5686         o_conv.is_owned = (o & 1) || (o == 0);
5687         o_conv = ChannelTransactionParameters_clone(&o_conv);
5688         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5689         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5690         return (long)ret_conv;
5691 }
5692
5693 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5694         LDKDecodeError e_conv;
5695         e_conv.inner = (void*)(e & (~1));
5696         e_conv.is_owned = (e & 1) || (e == 0);
5697         e_conv = DecodeError_clone(&e_conv);
5698         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5699         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
5700         return (long)ret_conv;
5701 }
5702
5703 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5704         if ((_res & 1) != 0) return;
5705         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5706         FREE((void*)_res);
5707         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5708 }
5709
5710 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5711         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5712         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5713         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5714         return (long)ret_conv;
5715 }
5716
5717 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
5718         LDKCVec_SignatureZ _res_constr;
5719         _res_constr.datalen = *((uint32_t*)_res);
5720         if (_res_constr.datalen > 0)
5721                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5722         else
5723                 _res_constr.data = NULL;
5724         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5725         for (size_t m = 0; m < _res_constr.datalen; m++) {
5726                 int8_tArray _res_conv_12 = _res_vals[m];
5727                 LDKSignature _res_conv_12_ref;
5728                 CHECK(*((uint32_t*)_res_conv_12) == 64);
5729                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
5730                 _res_constr.data[m] = _res_conv_12_ref;
5731         }
5732         CVec_SignatureZ_free(_res_constr);
5733 }
5734
5735 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5736         LDKHolderCommitmentTransaction o_conv;
5737         o_conv.inner = (void*)(o & (~1));
5738         o_conv.is_owned = (o & 1) || (o == 0);
5739         o_conv = HolderCommitmentTransaction_clone(&o_conv);
5740         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5741         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
5742         return (long)ret_conv;
5743 }
5744
5745 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5746         LDKDecodeError e_conv;
5747         e_conv.inner = (void*)(e & (~1));
5748         e_conv.is_owned = (e & 1) || (e == 0);
5749         e_conv = DecodeError_clone(&e_conv);
5750         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5751         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
5752         return (long)ret_conv;
5753 }
5754
5755 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5756         if ((_res & 1) != 0) return;
5757         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5758         FREE((void*)_res);
5759         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
5760 }
5761
5762 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5763         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5764         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5765         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5766         return (long)ret_conv;
5767 }
5768
5769 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5770         LDKBuiltCommitmentTransaction o_conv;
5771         o_conv.inner = (void*)(o & (~1));
5772         o_conv.is_owned = (o & 1) || (o == 0);
5773         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
5774         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5775         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
5776         return (long)ret_conv;
5777 }
5778
5779 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5780         LDKDecodeError e_conv;
5781         e_conv.inner = (void*)(e & (~1));
5782         e_conv.is_owned = (e & 1) || (e == 0);
5783         e_conv = DecodeError_clone(&e_conv);
5784         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5785         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
5786         return (long)ret_conv;
5787 }
5788
5789 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5790         if ((_res & 1) != 0) return;
5791         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5792         FREE((void*)_res);
5793         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
5794 }
5795
5796 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5797         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5798         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5799         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5800         return (long)ret_conv;
5801 }
5802
5803 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5804         LDKCommitmentTransaction o_conv;
5805         o_conv.inner = (void*)(o & (~1));
5806         o_conv.is_owned = (o & 1) || (o == 0);
5807         o_conv = CommitmentTransaction_clone(&o_conv);
5808         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5809         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
5810         return (long)ret_conv;
5811 }
5812
5813 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5814         LDKDecodeError e_conv;
5815         e_conv.inner = (void*)(e & (~1));
5816         e_conv.is_owned = (e & 1) || (e == 0);
5817         e_conv = DecodeError_clone(&e_conv);
5818         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5819         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
5820         return (long)ret_conv;
5821 }
5822
5823 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5824         if ((_res & 1) != 0) return;
5825         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5826         FREE((void*)_res);
5827         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
5828 }
5829
5830 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5831         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
5832         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5833         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
5834         return (long)ret_conv;
5835 }
5836
5837 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
5838         LDKTrustedCommitmentTransaction o_conv;
5839         o_conv.inner = (void*)(o & (~1));
5840         o_conv.is_owned = (o & 1) || (o == 0);
5841         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
5842         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5843         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5844         return (long)ret_conv;
5845 }
5846
5847 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
5848         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5849         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5850         return (long)ret_conv;
5851 }
5852
5853 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
5854         if ((_res & 1) != 0) return;
5855         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
5856         FREE((void*)_res);
5857         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5858 }
5859
5860 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
5861         LDKCVec_SignatureZ o_constr;
5862         o_constr.datalen = *((uint32_t*)o);
5863         if (o_constr.datalen > 0)
5864                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5865         else
5866                 o_constr.data = NULL;
5867         int8_tArray* o_vals = (int8_tArray*)(o + 4);
5868         for (size_t m = 0; m < o_constr.datalen; m++) {
5869                 int8_tArray o_conv_12 = o_vals[m];
5870                 LDKSignature o_conv_12_ref;
5871                 CHECK(*((uint32_t*)o_conv_12) == 64);
5872                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
5873                 o_constr.data[m] = o_conv_12_ref;
5874         }
5875         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5876         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
5877         return (long)ret_conv;
5878 }
5879
5880 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
5881         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5882         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
5883         return (long)ret_conv;
5884 }
5885
5886 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5887         if ((_res & 1) != 0) return;
5888         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
5889         FREE((void*)_res);
5890         CResult_CVec_SignatureZNoneZ_free(_res_conv);
5891 }
5892
5893 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
5894         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
5895         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5896         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
5897         return (long)ret_conv;
5898 }
5899
5900 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
5901         LDKCVec_MessageSendEventZ _res_constr;
5902         _res_constr.datalen = *((uint32_t*)_res);
5903         if (_res_constr.datalen > 0)
5904                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5905         else
5906                 _res_constr.data = NULL;
5907         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5908         for (size_t s = 0; s < _res_constr.datalen; s++) {
5909                 uint32_t _res_conv_18 = _res_vals[s];
5910                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
5911                 FREE((void*)_res_conv_18);
5912                 _res_constr.data[s] = _res_conv_18_conv;
5913         }
5914         CVec_MessageSendEventZ_free(_res_constr);
5915 }
5916
5917 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5918         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5919         *ret_conv = CResult_boolLightningErrorZ_ok(o);
5920         return (long)ret_conv;
5921 }
5922
5923 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5924         LDKLightningError e_conv;
5925         e_conv.inner = (void*)(e & (~1));
5926         e_conv.is_owned = (e & 1) || (e == 0);
5927         e_conv = LightningError_clone(&e_conv);
5928         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5929         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5930         return (long)ret_conv;
5931 }
5932
5933 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5934         if ((_res & 1) != 0) return;
5935         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
5936         FREE((void*)_res);
5937         CResult_boolLightningErrorZ_free(_res_conv);
5938 }
5939
5940 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
5941         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
5942         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5943         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
5944         return (long)ret_conv;
5945 }
5946
5947 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
5948         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
5949         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5950         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
5951         return (long)ret_ref;
5952 }
5953
5954 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5955         LDKChannelAnnouncement a_conv;
5956         a_conv.inner = (void*)(a & (~1));
5957         a_conv.is_owned = (a & 1) || (a == 0);
5958         a_conv = ChannelAnnouncement_clone(&a_conv);
5959         LDKChannelUpdate b_conv;
5960         b_conv.inner = (void*)(b & (~1));
5961         b_conv.is_owned = (b & 1) || (b == 0);
5962         b_conv = ChannelUpdate_clone(&b_conv);
5963         LDKChannelUpdate c_conv;
5964         c_conv.inner = (void*)(c & (~1));
5965         c_conv.is_owned = (c & 1) || (c == 0);
5966         c_conv = ChannelUpdate_clone(&c_conv);
5967         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5968         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5969         return (long)ret_ref;
5970 }
5971
5972 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5973         if ((_res & 1) != 0) return;
5974         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
5975         FREE((void*)_res);
5976         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5977 }
5978
5979 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5980         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5981         _res_constr.datalen = *((uint32_t*)_res);
5982         if (_res_constr.datalen > 0)
5983                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5984         else
5985                 _res_constr.data = NULL;
5986         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5987         for (size_t l = 0; l < _res_constr.datalen; l++) {
5988                 uint32_t _res_conv_63 = _res_vals[l];
5989                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
5990                 FREE((void*)_res_conv_63);
5991                 _res_constr.data[l] = _res_conv_63_conv;
5992         }
5993         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5994 }
5995
5996 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5997         LDKCVec_NodeAnnouncementZ _res_constr;
5998         _res_constr.datalen = *((uint32_t*)_res);
5999         if (_res_constr.datalen > 0)
6000                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6001         else
6002                 _res_constr.data = NULL;
6003         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6004         for (size_t s = 0; s < _res_constr.datalen; s++) {
6005                 uint32_t _res_conv_18 = _res_vals[s];
6006                 LDKNodeAnnouncement _res_conv_18_conv;
6007                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
6008                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
6009                 _res_constr.data[s] = _res_conv_18_conv;
6010         }
6011         CVec_NodeAnnouncementZ_free(_res_constr);
6012 }
6013
6014 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
6015         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6016         *ret_conv = CResult_NoneLightningErrorZ_ok();
6017         return (long)ret_conv;
6018 }
6019
6020 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
6021         LDKLightningError e_conv;
6022         e_conv.inner = (void*)(e & (~1));
6023         e_conv.is_owned = (e & 1) || (e == 0);
6024         e_conv = LightningError_clone(&e_conv);
6025         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6026         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
6027         return (long)ret_conv;
6028 }
6029
6030 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
6031         if ((_res & 1) != 0) return;
6032         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
6033         FREE((void*)_res);
6034         CResult_NoneLightningErrorZ_free(_res_conv);
6035 }
6036
6037 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
6038         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
6039         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6040         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
6041         return (long)ret_conv;
6042 }
6043
6044 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
6045         LDKCVec_PublicKeyZ _res_constr;
6046         _res_constr.datalen = *((uint32_t*)_res);
6047         if (_res_constr.datalen > 0)
6048                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
6049         else
6050                 _res_constr.data = NULL;
6051         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6052         for (size_t m = 0; m < _res_constr.datalen; m++) {
6053                 int8_tArray _res_conv_12 = _res_vals[m];
6054                 LDKPublicKey _res_conv_12_ref;
6055                 CHECK(*((uint32_t*)_res_conv_12) == 33);
6056                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
6057                 _res_constr.data[m] = _res_conv_12_ref;
6058         }
6059         CVec_PublicKeyZ_free(_res_constr);
6060 }
6061
6062 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
6063         LDKCVec_u8Z _res_ref;
6064         _res_ref.datalen = *((uint32_t*)_res);
6065         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
6066         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6067         CVec_u8Z_free(_res_ref);
6068 }
6069
6070 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
6071         LDKCVec_u8Z o_ref;
6072         o_ref.datalen = *((uint32_t*)o);
6073         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
6074         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
6075         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6076         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
6077         return (long)ret_conv;
6078 }
6079
6080 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
6081         LDKPeerHandleError e_conv;
6082         e_conv.inner = (void*)(e & (~1));
6083         e_conv.is_owned = (e & 1) || (e == 0);
6084         e_conv = PeerHandleError_clone(&e_conv);
6085         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6086         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
6087         return (long)ret_conv;
6088 }
6089
6090 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
6091         if ((_res & 1) != 0) return;
6092         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6093         FREE((void*)_res);
6094         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
6095 }
6096
6097 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
6098         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
6099         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6100         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
6101         return (long)ret_conv;
6102 }
6103
6104 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
6105         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6106         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
6107         return (long)ret_conv;
6108 }
6109
6110 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
6111         LDKPeerHandleError e_conv;
6112         e_conv.inner = (void*)(e & (~1));
6113         e_conv.is_owned = (e & 1) || (e == 0);
6114         e_conv = PeerHandleError_clone(&e_conv);
6115         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6116         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
6117         return (long)ret_conv;
6118 }
6119
6120 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
6121         if ((_res & 1) != 0) return;
6122         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6123         FREE((void*)_res);
6124         CResult_NonePeerHandleErrorZ_free(_res_conv);
6125 }
6126
6127 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
6128         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
6129         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6130         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
6131         return (long)ret_conv;
6132 }
6133
6134 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
6135         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6136         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
6137         return (long)ret_conv;
6138 }
6139
6140 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
6141         LDKPeerHandleError e_conv;
6142         e_conv.inner = (void*)(e & (~1));
6143         e_conv.is_owned = (e & 1) || (e == 0);
6144         e_conv = PeerHandleError_clone(&e_conv);
6145         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6146         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
6147         return (long)ret_conv;
6148 }
6149
6150 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
6151         if ((_res & 1) != 0) return;
6152         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6153         FREE((void*)_res);
6154         CResult_boolPeerHandleErrorZ_free(_res_conv);
6155 }
6156
6157 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
6158         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
6159         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6160         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
6161         return (long)ret_conv;
6162 }
6163
6164 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
6165         LDKInitFeatures o_conv;
6166         o_conv.inner = (void*)(o & (~1));
6167         o_conv.is_owned = (o & 1) || (o == 0);
6168         o_conv = InitFeatures_clone(&o_conv);
6169         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6170         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
6171         return (long)ret_conv;
6172 }
6173
6174 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
6175         LDKDecodeError e_conv;
6176         e_conv.inner = (void*)(e & (~1));
6177         e_conv.is_owned = (e & 1) || (e == 0);
6178         e_conv = DecodeError_clone(&e_conv);
6179         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6180         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
6181         return (long)ret_conv;
6182 }
6183
6184 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
6185         if ((_res & 1) != 0) return;
6186         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6187         FREE((void*)_res);
6188         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
6189 }
6190
6191 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
6192         LDKNodeFeatures o_conv;
6193         o_conv.inner = (void*)(o & (~1));
6194         o_conv.is_owned = (o & 1) || (o == 0);
6195         o_conv = NodeFeatures_clone(&o_conv);
6196         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6197         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
6198         return (long)ret_conv;
6199 }
6200
6201 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
6202         LDKDecodeError e_conv;
6203         e_conv.inner = (void*)(e & (~1));
6204         e_conv.is_owned = (e & 1) || (e == 0);
6205         e_conv = DecodeError_clone(&e_conv);
6206         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6207         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
6208         return (long)ret_conv;
6209 }
6210
6211 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
6212         if ((_res & 1) != 0) return;
6213         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6214         FREE((void*)_res);
6215         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
6216 }
6217
6218 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
6219         LDKChannelFeatures o_conv;
6220         o_conv.inner = (void*)(o & (~1));
6221         o_conv.is_owned = (o & 1) || (o == 0);
6222         o_conv = ChannelFeatures_clone(&o_conv);
6223         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6224         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
6225         return (long)ret_conv;
6226 }
6227
6228 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
6229         LDKDecodeError e_conv;
6230         e_conv.inner = (void*)(e & (~1));
6231         e_conv.is_owned = (e & 1) || (e == 0);
6232         e_conv = DecodeError_clone(&e_conv);
6233         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6234         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
6235         return (long)ret_conv;
6236 }
6237
6238 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
6239         if ((_res & 1) != 0) return;
6240         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6241         FREE((void*)_res);
6242         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
6243 }
6244
6245 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
6246         LDKInvoiceFeatures o_conv;
6247         o_conv.inner = (void*)(o & (~1));
6248         o_conv.is_owned = (o & 1) || (o == 0);
6249         o_conv = InvoiceFeatures_clone(&o_conv);
6250         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
6251         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
6252         return (long)ret_conv;
6253 }
6254
6255 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
6256         LDKDecodeError e_conv;
6257         e_conv.inner = (void*)(e & (~1));
6258         e_conv.is_owned = (e & 1) || (e == 0);
6259         e_conv = DecodeError_clone(&e_conv);
6260         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
6261         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
6262         return (long)ret_conv;
6263 }
6264
6265 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
6266         if ((_res & 1) != 0) return;
6267         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6268         FREE((void*)_res);
6269         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
6270 }
6271
6272 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
6273         LDKChannelConfig o_conv;
6274         o_conv.inner = (void*)(o & (~1));
6275         o_conv.is_owned = (o & 1) || (o == 0);
6276         o_conv = ChannelConfig_clone(&o_conv);
6277         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6278         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6279         return (long)ret_conv;
6280 }
6281
6282 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
6283         LDKDecodeError e_conv;
6284         e_conv.inner = (void*)(e & (~1));
6285         e_conv.is_owned = (e & 1) || (e == 0);
6286         e_conv = DecodeError_clone(&e_conv);
6287         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6288         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6289         return (long)ret_conv;
6290 }
6291
6292 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
6293         if ((_res & 1) != 0) return;
6294         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6295         FREE((void*)_res);
6296         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6297 }
6298
6299 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
6300         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6301         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6302         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6303         return (long)ret_conv;
6304 }
6305
6306 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
6307         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6308         *ret_copy = COption_u64Z_some(o);
6309         long ret_ref = (long)ret_copy;
6310         return ret_ref;
6311 }
6312
6313 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
6314         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6315         *ret_copy = COption_u64Z_none();
6316         long ret_ref = (long)ret_copy;
6317         return ret_ref;
6318 }
6319
6320 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
6321         if ((_res & 1) != 0) return;
6322         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
6323         FREE((void*)_res);
6324         COption_u64Z_free(_res_conv);
6325 }
6326
6327 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
6328         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
6329         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6330         *ret_copy = COption_u64Z_clone(orig_conv);
6331         long ret_ref = (long)ret_copy;
6332         return ret_ref;
6333 }
6334
6335 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
6336         LDKDirectionalChannelInfo o_conv;
6337         o_conv.inner = (void*)(o & (~1));
6338         o_conv.is_owned = (o & 1) || (o == 0);
6339         o_conv = DirectionalChannelInfo_clone(&o_conv);
6340         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6341         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
6342         return (long)ret_conv;
6343 }
6344
6345 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
6346         LDKDecodeError e_conv;
6347         e_conv.inner = (void*)(e & (~1));
6348         e_conv.is_owned = (e & 1) || (e == 0);
6349         e_conv = DecodeError_clone(&e_conv);
6350         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6351         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
6352         return (long)ret_conv;
6353 }
6354
6355 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
6356         if ((_res & 1) != 0) return;
6357         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6358         FREE((void*)_res);
6359         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
6360 }
6361
6362 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6363         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
6364         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6365         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
6366         return (long)ret_conv;
6367 }
6368
6369 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
6370         LDKChannelInfo o_conv;
6371         o_conv.inner = (void*)(o & (~1));
6372         o_conv.is_owned = (o & 1) || (o == 0);
6373         o_conv = ChannelInfo_clone(&o_conv);
6374         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6375         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
6376         return (long)ret_conv;
6377 }
6378
6379 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
6380         LDKDecodeError e_conv;
6381         e_conv.inner = (void*)(e & (~1));
6382         e_conv.is_owned = (e & 1) || (e == 0);
6383         e_conv = DecodeError_clone(&e_conv);
6384         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6385         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
6386         return (long)ret_conv;
6387 }
6388
6389 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
6390         if ((_res & 1) != 0) return;
6391         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6392         FREE((void*)_res);
6393         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
6394 }
6395
6396 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6397         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
6398         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6399         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
6400         return (long)ret_conv;
6401 }
6402
6403 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6404         LDKRoutingFees o_conv;
6405         o_conv.inner = (void*)(o & (~1));
6406         o_conv.is_owned = (o & 1) || (o == 0);
6407         o_conv = RoutingFees_clone(&o_conv);
6408         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6409         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6410         return (long)ret_conv;
6411 }
6412
6413 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6414         LDKDecodeError e_conv;
6415         e_conv.inner = (void*)(e & (~1));
6416         e_conv.is_owned = (e & 1) || (e == 0);
6417         e_conv = DecodeError_clone(&e_conv);
6418         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6419         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6420         return (long)ret_conv;
6421 }
6422
6423 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6424         if ((_res & 1) != 0) return;
6425         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6426         FREE((void*)_res);
6427         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6428 }
6429
6430 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
6431         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
6432         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6433         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
6434         return (long)ret_conv;
6435 }
6436
6437 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
6438         LDKCVec_NetAddressZ _res_constr;
6439         _res_constr.datalen = *((uint32_t*)_res);
6440         if (_res_constr.datalen > 0)
6441                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6442         else
6443                 _res_constr.data = NULL;
6444         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6445         for (size_t m = 0; m < _res_constr.datalen; m++) {
6446                 uint32_t _res_conv_12 = _res_vals[m];
6447                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
6448                 FREE((void*)_res_conv_12);
6449                 _res_constr.data[m] = _res_conv_12_conv;
6450         }
6451         CVec_NetAddressZ_free(_res_constr);
6452 }
6453
6454 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6455         LDKNodeAnnouncementInfo o_conv;
6456         o_conv.inner = (void*)(o & (~1));
6457         o_conv.is_owned = (o & 1) || (o == 0);
6458         o_conv = NodeAnnouncementInfo_clone(&o_conv);
6459         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6460         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6461         return (long)ret_conv;
6462 }
6463
6464 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6465         LDKDecodeError e_conv;
6466         e_conv.inner = (void*)(e & (~1));
6467         e_conv.is_owned = (e & 1) || (e == 0);
6468         e_conv = DecodeError_clone(&e_conv);
6469         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6470         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6471         return (long)ret_conv;
6472 }
6473
6474 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6475         if ((_res & 1) != 0) return;
6476         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6477         FREE((void*)_res);
6478         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6479 }
6480
6481 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
6482         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
6483         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6484         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
6485         return (long)ret_conv;
6486 }
6487
6488 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
6489         LDKCVec_u64Z _res_constr;
6490         _res_constr.datalen = *((uint32_t*)_res);
6491         if (_res_constr.datalen > 0)
6492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
6493         else
6494                 _res_constr.data = NULL;
6495         int64_t* _res_vals = (int64_t*)(_res + 4);
6496         for (size_t i = 0; i < _res_constr.datalen; i++) {
6497                 int64_t _res_conv_8 = _res_vals[i];
6498                 _res_constr.data[i] = _res_conv_8;
6499         }
6500         CVec_u64Z_free(_res_constr);
6501 }
6502
6503 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6504         LDKNodeInfo o_conv;
6505         o_conv.inner = (void*)(o & (~1));
6506         o_conv.is_owned = (o & 1) || (o == 0);
6507         o_conv = NodeInfo_clone(&o_conv);
6508         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6509         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6510         return (long)ret_conv;
6511 }
6512
6513 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6514         LDKDecodeError e_conv;
6515         e_conv.inner = (void*)(e & (~1));
6516         e_conv.is_owned = (e & 1) || (e == 0);
6517         e_conv = DecodeError_clone(&e_conv);
6518         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6519         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6520         return (long)ret_conv;
6521 }
6522
6523 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6524         if ((_res & 1) != 0) return;
6525         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6526         FREE((void*)_res);
6527         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6528 }
6529
6530 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
6531         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
6532         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6533         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
6534         return (long)ret_conv;
6535 }
6536
6537 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6538         LDKNetworkGraph o_conv;
6539         o_conv.inner = (void*)(o & (~1));
6540         o_conv.is_owned = (o & 1) || (o == 0);
6541         o_conv = NetworkGraph_clone(&o_conv);
6542         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6543         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6544         return (long)ret_conv;
6545 }
6546
6547 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6548         LDKDecodeError e_conv;
6549         e_conv.inner = (void*)(e & (~1));
6550         e_conv.is_owned = (e & 1) || (e == 0);
6551         e_conv = DecodeError_clone(&e_conv);
6552         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6553         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6554         return (long)ret_conv;
6555 }
6556
6557 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6558         if ((_res & 1) != 0) return;
6559         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
6560         FREE((void*)_res);
6561         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6562 }
6563
6564 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
6565         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
6566         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6567         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
6568         return (long)ret_conv;
6569 }
6570
6571 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
6572         LDKTransaction b_ref;
6573         b_ref.datalen = *((uint32_t*)b);
6574         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
6575         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6576         b_ref.data_is_owned = true;
6577         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6578         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
6579         return (long)ret_ref;
6580 }
6581
6582 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
6583         if ((_res & 1) != 0) return;
6584         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
6585         FREE((void*)_res);
6586         C2Tuple_usizeTransactionZ_free(_res_conv);
6587 }
6588
6589 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
6590         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
6591         _res_constr.datalen = *((uint32_t*)_res);
6592         if (_res_constr.datalen > 0)
6593                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6594         else
6595                 _res_constr.data = NULL;
6596         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6597         for (size_t e = 0; e < _res_constr.datalen; e++) {
6598                 uint32_t _res_conv_30 = _res_vals[e];
6599                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
6600                 FREE((void*)_res_conv_30);
6601                 _res_constr.data[e] = _res_conv_30_conv;
6602         }
6603         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
6604 }
6605
6606 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
6607         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6608         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
6609         return (long)ret_conv;
6610 }
6611
6612 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
6613         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
6614         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6615         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
6616         return (long)ret_conv;
6617 }
6618
6619 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
6620         if ((_res & 1) != 0) return;
6621         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
6622         FREE((void*)_res);
6623         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
6624 }
6625
6626 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
6627         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
6628         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6629         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
6630         return (long)ret_conv;
6631 }
6632
6633 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
6634         LDKCVec_MonitorEventZ _res_constr;
6635         _res_constr.datalen = *((uint32_t*)_res);
6636         if (_res_constr.datalen > 0)
6637                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6638         else
6639                 _res_constr.data = NULL;
6640         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6641         for (size_t o = 0; o < _res_constr.datalen; o++) {
6642                 uint32_t _res_conv_14 = _res_vals[o];
6643                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
6644                 FREE((void*)_res_conv_14);
6645                 _res_constr.data[o] = _res_conv_14_conv;
6646         }
6647         CVec_MonitorEventZ_free(_res_constr);
6648 }
6649
6650 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
6651         LDKCVec_EventZ _res_constr;
6652         _res_constr.datalen = *((uint32_t*)_res);
6653         if (_res_constr.datalen > 0)
6654                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
6655         else
6656                 _res_constr.data = NULL;
6657         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6658         for (size_t h = 0; h < _res_constr.datalen; h++) {
6659                 uint32_t _res_conv_7 = _res_vals[h];
6660                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
6661                 FREE((void*)_res_conv_7);
6662                 _res_constr.data[h] = _res_conv_7_conv;
6663         }
6664         CVec_EventZ_free(_res_constr);
6665 }
6666
6667 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
6668         LDKOutPoint o_conv;
6669         o_conv.inner = (void*)(o & (~1));
6670         o_conv.is_owned = (o & 1) || (o == 0);
6671         o_conv = OutPoint_clone(&o_conv);
6672         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6673         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
6674         return (long)ret_conv;
6675 }
6676
6677 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
6678         LDKDecodeError e_conv;
6679         e_conv.inner = (void*)(e & (~1));
6680         e_conv.is_owned = (e & 1) || (e == 0);
6681         e_conv = DecodeError_clone(&e_conv);
6682         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6683         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
6684         return (long)ret_conv;
6685 }
6686
6687 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
6688         if ((_res & 1) != 0) return;
6689         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
6690         FREE((void*)_res);
6691         CResult_OutPointDecodeErrorZ_free(_res_conv);
6692 }
6693
6694 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
6695         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
6696         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6697         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
6698         return (long)ret_conv;
6699 }
6700
6701 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
6702         LDKChannelMonitorUpdate o_conv;
6703         o_conv.inner = (void*)(o & (~1));
6704         o_conv.is_owned = (o & 1) || (o == 0);
6705         o_conv = ChannelMonitorUpdate_clone(&o_conv);
6706         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6707         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
6708         return (long)ret_conv;
6709 }
6710
6711 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
6712         LDKDecodeError e_conv;
6713         e_conv.inner = (void*)(e & (~1));
6714         e_conv.is_owned = (e & 1) || (e == 0);
6715         e_conv = DecodeError_clone(&e_conv);
6716         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6717         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
6718         return (long)ret_conv;
6719 }
6720
6721 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
6722         if ((_res & 1) != 0) return;
6723         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6724         FREE((void*)_res);
6725         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
6726 }
6727
6728 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
6729         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
6730         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6731         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
6732         return (long)ret_conv;
6733 }
6734
6735 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
6736         LDKHTLCUpdate o_conv;
6737         o_conv.inner = (void*)(o & (~1));
6738         o_conv.is_owned = (o & 1) || (o == 0);
6739         o_conv = HTLCUpdate_clone(&o_conv);
6740         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6741         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
6742         return (long)ret_conv;
6743 }
6744
6745 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
6746         LDKDecodeError e_conv;
6747         e_conv.inner = (void*)(e & (~1));
6748         e_conv.is_owned = (e & 1) || (e == 0);
6749         e_conv = DecodeError_clone(&e_conv);
6750         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6751         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
6752         return (long)ret_conv;
6753 }
6754
6755 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
6756         if ((_res & 1) != 0) return;
6757         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6758         FREE((void*)_res);
6759         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
6760 }
6761
6762 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
6763         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
6764         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6765         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
6766         return (long)ret_conv;
6767 }
6768
6769 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
6770         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6771         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
6772         return (long)ret_conv;
6773 }
6774
6775 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
6776         LDKMonitorUpdateError e_conv;
6777         e_conv.inner = (void*)(e & (~1));
6778         e_conv.is_owned = (e & 1) || (e == 0);
6779         e_conv = MonitorUpdateError_clone(&e_conv);
6780         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6781         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
6782         return (long)ret_conv;
6783 }
6784
6785 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
6786         if ((_res & 1) != 0) return;
6787         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
6788         FREE((void*)_res);
6789         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
6790 }
6791
6792 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
6793         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
6794         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6795         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
6796         return (long)ret_conv;
6797 }
6798
6799 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
6800         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
6801         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6802         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
6803         return (long)ret_ref;
6804 }
6805
6806 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
6807         LDKOutPoint a_conv;
6808         a_conv.inner = (void*)(a & (~1));
6809         a_conv.is_owned = (a & 1) || (a == 0);
6810         a_conv = OutPoint_clone(&a_conv);
6811         LDKCVec_u8Z b_ref;
6812         b_ref.datalen = *((uint32_t*)b);
6813         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6814         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6815         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6816         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
6817         return (long)ret_ref;
6818 }
6819
6820 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
6821         if ((_res & 1) != 0) return;
6822         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
6823         FREE((void*)_res);
6824         C2Tuple_OutPointScriptZ_free(_res_conv);
6825 }
6826
6827 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
6828         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
6829         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6830         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
6831         return (long)ret_ref;
6832 }
6833
6834 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
6835         LDKCVec_u8Z b_ref;
6836         b_ref.datalen = *((uint32_t*)b);
6837         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6838         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6839         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6840         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
6841         return (long)ret_ref;
6842 }
6843
6844 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
6845         if ((_res & 1) != 0) return;
6846         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
6847         FREE((void*)_res);
6848         C2Tuple_u32ScriptZ_free(_res_conv);
6849 }
6850
6851 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
6852         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
6853         _res_constr.datalen = *((uint32_t*)_res);
6854         if (_res_constr.datalen > 0)
6855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6856         else
6857                 _res_constr.data = NULL;
6858         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6859         for (size_t e = 0; e < _res_constr.datalen; e++) {
6860                 uint32_t _res_conv_30 = _res_vals[e];
6861                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
6862                 FREE((void*)_res_conv_30);
6863                 _res_constr.data[e] = _res_conv_30_conv;
6864         }
6865         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
6866 }
6867
6868 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
6869         LDKThirtyTwoBytes a_ref;
6870         CHECK(*((uint32_t*)a) == 32);
6871         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6872         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
6873         b_constr.datalen = *((uint32_t*)b);
6874         if (b_constr.datalen > 0)
6875                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6876         else
6877                 b_constr.data = NULL;
6878         uint32_t* b_vals = (uint32_t*)(b + 4);
6879         for (size_t e = 0; e < b_constr.datalen; e++) {
6880                 uint32_t b_conv_30 = b_vals[e];
6881                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
6882                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
6883                 b_constr.data[e] = b_conv_30_conv;
6884         }
6885         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
6886         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
6887         return (long)ret_ref;
6888 }
6889
6890 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
6891         if ((_res & 1) != 0) return;
6892         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
6893         FREE((void*)_res);
6894         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
6895 }
6896
6897 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
6898         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
6899         _res_constr.datalen = *((uint32_t*)_res);
6900         if (_res_constr.datalen > 0)
6901                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
6902         else
6903                 _res_constr.data = NULL;
6904         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6905         for (size_t c = 0; c < _res_constr.datalen; c++) {
6906                 uint32_t _res_conv_54 = _res_vals[c];
6907                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
6908                 FREE((void*)_res_conv_54);
6909                 _res_constr.data[c] = _res_conv_54_conv;
6910         }
6911         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
6912 }
6913
6914 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
6915         LDKCVec_TransactionZ _res_constr;
6916         _res_constr.datalen = *((uint32_t*)_res);
6917         if (_res_constr.datalen > 0)
6918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6919         else
6920                 _res_constr.data = NULL;
6921         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6922         for (size_t m = 0; m < _res_constr.datalen; m++) {
6923                 int8_tArray _res_conv_12 = _res_vals[m];
6924                 LDKTransaction _res_conv_12_ref;
6925                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
6926                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
6927                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
6928                 _res_conv_12_ref.data_is_owned = true;
6929                 _res_constr.data[m] = _res_conv_12_ref;
6930         }
6931         CVec_TransactionZ_free(_res_constr);
6932 }
6933
6934 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
6935         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
6936         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6937         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
6938         return (long)ret_ref;
6939 }
6940
6941 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
6942         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
6943         FREE((void*)b);
6944         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6945         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
6946         return (long)ret_ref;
6947 }
6948
6949 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
6950         if ((_res & 1) != 0) return;
6951         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
6952         FREE((void*)_res);
6953         C2Tuple_u32TxOutZ_free(_res_conv);
6954 }
6955
6956 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
6957         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
6958         _res_constr.datalen = *((uint32_t*)_res);
6959         if (_res_constr.datalen > 0)
6960                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6961         else
6962                 _res_constr.data = NULL;
6963         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6964         for (size_t z = 0; z < _res_constr.datalen; z++) {
6965                 uint32_t _res_conv_25 = _res_vals[z];
6966                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
6967                 FREE((void*)_res_conv_25);
6968                 _res_constr.data[z] = _res_conv_25_conv;
6969         }
6970         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
6971 }
6972
6973 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
6974         LDKThirtyTwoBytes a_ref;
6975         CHECK(*((uint32_t*)a) == 32);
6976         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6977         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
6978         b_constr.datalen = *((uint32_t*)b);
6979         if (b_constr.datalen > 0)
6980                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6981         else
6982                 b_constr.data = NULL;
6983         uint32_t* b_vals = (uint32_t*)(b + 4);
6984         for (size_t z = 0; z < b_constr.datalen; z++) {
6985                 uint32_t b_conv_25 = b_vals[z];
6986                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
6987                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
6988                 b_constr.data[z] = b_conv_25_conv;
6989         }
6990         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
6991         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
6992         return (long)ret_ref;
6993 }
6994
6995 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
6996         if ((_res & 1) != 0) return;
6997         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
6998         FREE((void*)_res);
6999         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
7000 }
7001
7002 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
7003         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
7004         _res_constr.datalen = *((uint32_t*)_res);
7005         if (_res_constr.datalen > 0)
7006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
7007         else
7008                 _res_constr.data = NULL;
7009         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7010         for (size_t x = 0; x < _res_constr.datalen; x++) {
7011                 uint32_t _res_conv_49 = _res_vals[x];
7012                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
7013                 FREE((void*)_res_conv_49);
7014                 _res_constr.data[x] = _res_conv_49_conv;
7015         }
7016         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
7017 }
7018
7019 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
7020         LDKThirtyTwoBytes a_ref;
7021         CHECK(*((uint32_t*)a) == 32);
7022         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7023         LDKChannelMonitor b_conv;
7024         b_conv.inner = (void*)(b & (~1));
7025         b_conv.is_owned = (b & 1) || (b == 0);
7026         b_conv = ChannelMonitor_clone(&b_conv);
7027         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7028         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7029         return (long)ret_ref;
7030 }
7031
7032 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
7033         if ((_res & 1) != 0) return;
7034         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7035         FREE((void*)_res);
7036         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7037 }
7038
7039 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
7040         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
7041         FREE((void*)o);
7042         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7043         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
7044         return (long)ret_conv;
7045 }
7046
7047 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
7048         LDKDecodeError e_conv;
7049         e_conv.inner = (void*)(e & (~1));
7050         e_conv.is_owned = (e & 1) || (e == 0);
7051         e_conv = DecodeError_clone(&e_conv);
7052         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7053         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
7054         return (long)ret_conv;
7055 }
7056
7057 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
7058         if ((_res & 1) != 0) return;
7059         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7060         FREE((void*)_res);
7061         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
7062 }
7063
7064 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7065         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7066         _res_constr.datalen = *((uint32_t*)_res);
7067         if (_res_constr.datalen > 0)
7068                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7069         else
7070                 _res_constr.data = NULL;
7071         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7072         for (size_t b = 0; b < _res_constr.datalen; b++) {
7073                 uint32_t _res_conv_27 = _res_vals[b];
7074                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7075                 FREE((void*)_res_conv_27);
7076                 _res_constr.data[b] = _res_conv_27_conv;
7077         }
7078         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7079 }
7080
7081 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7082         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7083         FREE((void*)o);
7084         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7085         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7086         return (long)ret_conv;
7087 }
7088
7089 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7090         LDKAccessError e_conv = LDKAccessError_from_js(e);
7091         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7092         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7093         return (long)ret_conv;
7094 }
7095
7096 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7097         if ((_res & 1) != 0) return;
7098         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7099         FREE((void*)_res);
7100         CResult_TxOutAccessErrorZ_free(_res_conv);
7101 }
7102
7103 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7104         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7105         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7106         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7107         return (long)ret_conv;
7108 }
7109
7110 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7111         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7112         FREE((void*)o);
7113         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7114         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7115         long ret_ref = (long)ret_copy;
7116         return ret_ref;
7117 }
7118
7119 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7120         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7121         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7122         long ret_ref = (long)ret_copy;
7123         return ret_ref;
7124 }
7125
7126 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7127         if ((_res & 1) != 0) return;
7128         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7129         FREE((void*)_res);
7130         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7131 }
7132
7133 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
7134         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7135         *ret_conv = CResult_NoneAPIErrorZ_ok();
7136         return (long)ret_conv;
7137 }
7138
7139 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
7140         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7141         FREE((void*)e);
7142         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7143         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7144         return (long)ret_conv;
7145 }
7146
7147 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
7148         if ((_res & 1) != 0) return;
7149         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7150         FREE((void*)_res);
7151         CResult_NoneAPIErrorZ_free(_res_conv);
7152 }
7153
7154 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
7155         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7156         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7157         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7158         return (long)ret_conv;
7159 }
7160
7161 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
7162         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
7163         _res_constr.datalen = *((uint32_t*)_res);
7164         if (_res_constr.datalen > 0)
7165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
7166         else
7167                 _res_constr.data = NULL;
7168         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7169         for (size_t w = 0; w < _res_constr.datalen; w++) {
7170                 uint32_t _res_conv_22 = _res_vals[w];
7171                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
7172                 FREE((void*)_res_conv_22);
7173                 _res_constr.data[w] = _res_conv_22_conv;
7174         }
7175         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
7176 }
7177
7178 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
7179         LDKCVec_APIErrorZ _res_constr;
7180         _res_constr.datalen = *((uint32_t*)_res);
7181         if (_res_constr.datalen > 0)
7182                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
7183         else
7184                 _res_constr.data = NULL;
7185         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7186         for (size_t k = 0; k < _res_constr.datalen; k++) {
7187                 uint32_t _res_conv_10 = _res_vals[k];
7188                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
7189                 FREE((void*)_res_conv_10);
7190                 _res_constr.data[k] = _res_conv_10_conv;
7191         }
7192         CVec_APIErrorZ_free(_res_constr);
7193 }
7194
7195 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7196         LDKCVec_ChannelDetailsZ _res_constr;
7197         _res_constr.datalen = *((uint32_t*)_res);
7198         if (_res_constr.datalen > 0)
7199                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7200         else
7201                 _res_constr.data = NULL;
7202         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7203         for (size_t q = 0; q < _res_constr.datalen; q++) {
7204                 uint32_t _res_conv_16 = _res_vals[q];
7205                 LDKChannelDetails _res_conv_16_conv;
7206                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7207                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7208                 _res_constr.data[q] = _res_conv_16_conv;
7209         }
7210         CVec_ChannelDetailsZ_free(_res_constr);
7211 }
7212
7213 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
7214         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7215         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7216         return (long)ret_conv;
7217 }
7218
7219 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
7220         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
7221         FREE((void*)e);
7222         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7223         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7224         return (long)ret_conv;
7225 }
7226
7227 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
7228         if ((_res & 1) != 0) return;
7229         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
7230         FREE((void*)_res);
7231         CResult_NonePaymentSendFailureZ_free(_res_conv);
7232 }
7233
7234 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
7235         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
7236         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7237         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
7238         return (long)ret_conv;
7239 }
7240
7241 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
7242         LDKCVec_ChannelMonitorZ _res_constr;
7243         _res_constr.datalen = *((uint32_t*)_res);
7244         if (_res_constr.datalen > 0)
7245                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7246         else
7247                 _res_constr.data = NULL;
7248         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7249         for (size_t q = 0; q < _res_constr.datalen; q++) {
7250                 uint32_t _res_conv_16 = _res_vals[q];
7251                 LDKChannelMonitor _res_conv_16_conv;
7252                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7253                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7254                 _res_constr.data[q] = _res_conv_16_conv;
7255         }
7256         CVec_ChannelMonitorZ_free(_res_constr);
7257 }
7258
7259 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
7260         LDKThirtyTwoBytes a_ref;
7261         CHECK(*((uint32_t*)a) == 32);
7262         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7263         LDKChannelManager b_conv;
7264         b_conv.inner = (void*)(b & (~1));
7265         b_conv.is_owned = (b & 1) || (b == 0);
7266         // Warning: we need a move here but no clone is available for LDKChannelManager
7267         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
7268         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
7269         return (long)ret_ref;
7270 }
7271
7272 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
7273         if ((_res & 1) != 0) return;
7274         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
7275         FREE((void*)_res);
7276         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
7277 }
7278
7279 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
7280         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
7281         FREE((void*)o);
7282         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7283         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
7284         return (long)ret_conv;
7285 }
7286
7287 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
7288         LDKDecodeError e_conv;
7289         e_conv.inner = (void*)(e & (~1));
7290         e_conv.is_owned = (e & 1) || (e == 0);
7291         e_conv = DecodeError_clone(&e_conv);
7292         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7293         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
7294         return (long)ret_conv;
7295 }
7296
7297 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
7298         if ((_res & 1) != 0) return;
7299         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7300         FREE((void*)_res);
7301         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
7302 }
7303
7304 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7305         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7306         FREE((void*)o);
7307         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7308         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7309         return (long)ret_conv;
7310 }
7311
7312 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7313         LDKDecodeError e_conv;
7314         e_conv.inner = (void*)(e & (~1));
7315         e_conv.is_owned = (e & 1) || (e == 0);
7316         e_conv = DecodeError_clone(&e_conv);
7317         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7318         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7319         return (long)ret_conv;
7320 }
7321
7322 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7323         if ((_res & 1) != 0) return;
7324         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7325         FREE((void*)_res);
7326         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7327 }
7328
7329 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7330         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7331         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7332         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7333         return (long)ret_conv;
7334 }
7335
7336 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7337         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7338         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7339         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7340         return (long)ret_ref;
7341 }
7342
7343 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7344         LDKSignature a_ref;
7345         CHECK(*((uint32_t*)a) == 64);
7346         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7347         LDKCVec_SignatureZ b_constr;
7348         b_constr.datalen = *((uint32_t*)b);
7349         if (b_constr.datalen > 0)
7350                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7351         else
7352                 b_constr.data = NULL;
7353         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7354         for (size_t m = 0; m < b_constr.datalen; m++) {
7355                 int8_tArray b_conv_12 = b_vals[m];
7356                 LDKSignature b_conv_12_ref;
7357                 CHECK(*((uint32_t*)b_conv_12) == 64);
7358                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7359                 b_constr.data[m] = b_conv_12_ref;
7360         }
7361         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7362         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7363         return (long)ret_ref;
7364 }
7365
7366 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7367         if ((_res & 1) != 0) return;
7368         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7369         FREE((void*)_res);
7370         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7371 }
7372
7373 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7374         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7375         FREE((void*)o);
7376         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7377         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7378         return (long)ret_conv;
7379 }
7380
7381 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7382         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7383         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7384         return (long)ret_conv;
7385 }
7386
7387 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7388         if ((_res & 1) != 0) return;
7389         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7390         FREE((void*)_res);
7391         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7392 }
7393
7394 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7395         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7396         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7397         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7398         return (long)ret_conv;
7399 }
7400
7401 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7402         LDKSignature o_ref;
7403         CHECK(*((uint32_t*)o) == 64);
7404         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7405         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7406         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7407         return (long)ret_conv;
7408 }
7409
7410 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7411         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7412         *ret_conv = CResult_SignatureNoneZ_err();
7413         return (long)ret_conv;
7414 }
7415
7416 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7417         if ((_res & 1) != 0) return;
7418         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7419         FREE((void*)_res);
7420         CResult_SignatureNoneZ_free(_res_conv);
7421 }
7422
7423 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7424         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7425         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7426         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7427         return (long)ret_conv;
7428 }
7429
7430 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7431         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7432         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7433         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7434         return (long)ret_conv;
7435 }
7436
7437 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7438         LDKDecodeError e_conv;
7439         e_conv.inner = (void*)(e & (~1));
7440         e_conv.is_owned = (e & 1) || (e == 0);
7441         e_conv = DecodeError_clone(&e_conv);
7442         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7443         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7444         return (long)ret_conv;
7445 }
7446
7447 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7448         if ((_res & 1) != 0) return;
7449         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7450         FREE((void*)_res);
7451         CResult_SignDecodeErrorZ_free(_res_conv);
7452 }
7453
7454 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7455         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7456         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7457         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7458         return (long)ret_conv;
7459 }
7460
7461 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7462         LDKCVec_CVec_u8ZZ _res_constr;
7463         _res_constr.datalen = *((uint32_t*)_res);
7464         if (_res_constr.datalen > 0)
7465                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7466         else
7467                 _res_constr.data = NULL;
7468         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7469         for (size_t m = 0; m < _res_constr.datalen; m++) {
7470                 int8_tArray _res_conv_12 = _res_vals[m];
7471                 LDKCVec_u8Z _res_conv_12_ref;
7472                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7473                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7474                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7475                 _res_constr.data[m] = _res_conv_12_ref;
7476         }
7477         CVec_CVec_u8ZZ_free(_res_constr);
7478 }
7479
7480 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7481         LDKCVec_CVec_u8ZZ o_constr;
7482         o_constr.datalen = *((uint32_t*)o);
7483         if (o_constr.datalen > 0)
7484                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7485         else
7486                 o_constr.data = NULL;
7487         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7488         for (size_t m = 0; m < o_constr.datalen; m++) {
7489                 int8_tArray o_conv_12 = o_vals[m];
7490                 LDKCVec_u8Z o_conv_12_ref;
7491                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7492                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7493                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7494                 o_constr.data[m] = o_conv_12_ref;
7495         }
7496         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7497         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7498         return (long)ret_conv;
7499 }
7500
7501 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7502         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7503         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7504         return (long)ret_conv;
7505 }
7506
7507 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7508         if ((_res & 1) != 0) return;
7509         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7510         FREE((void*)_res);
7511         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7512 }
7513
7514 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7515         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7516         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7517         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7518         return (long)ret_conv;
7519 }
7520
7521 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7522         LDKInMemorySigner o_conv;
7523         o_conv.inner = (void*)(o & (~1));
7524         o_conv.is_owned = (o & 1) || (o == 0);
7525         o_conv = InMemorySigner_clone(&o_conv);
7526         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7527         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7528         return (long)ret_conv;
7529 }
7530
7531 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7532         LDKDecodeError e_conv;
7533         e_conv.inner = (void*)(e & (~1));
7534         e_conv.is_owned = (e & 1) || (e == 0);
7535         e_conv = DecodeError_clone(&e_conv);
7536         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7537         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7538         return (long)ret_conv;
7539 }
7540
7541 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7542         if ((_res & 1) != 0) return;
7543         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7544         FREE((void*)_res);
7545         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7546 }
7547
7548 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7549         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7550         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7551         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7552         return (long)ret_conv;
7553 }
7554
7555 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7556         LDKCVec_TxOutZ _res_constr;
7557         _res_constr.datalen = *((uint32_t*)_res);
7558         if (_res_constr.datalen > 0)
7559                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7560         else
7561                 _res_constr.data = NULL;
7562         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7563         for (size_t h = 0; h < _res_constr.datalen; h++) {
7564                 uint32_t _res_conv_7 = _res_vals[h];
7565                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7566                 FREE((void*)_res_conv_7);
7567                 _res_constr.data[h] = _res_conv_7_conv;
7568         }
7569         CVec_TxOutZ_free(_res_constr);
7570 }
7571
7572 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7573         LDKTransaction o_ref;
7574         o_ref.datalen = *((uint32_t*)o);
7575         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7576         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7577         o_ref.data_is_owned = true;
7578         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7579         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7580         return (long)ret_conv;
7581 }
7582
7583 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7584         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7585         *ret_conv = CResult_TransactionNoneZ_err();
7586         return (long)ret_conv;
7587 }
7588
7589 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7590         if ((_res & 1) != 0) return;
7591         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7592         FREE((void*)_res);
7593         CResult_TransactionNoneZ_free(_res_conv);
7594 }
7595
7596 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7597         LDKCVec_RouteHopZ _res_constr;
7598         _res_constr.datalen = *((uint32_t*)_res);
7599         if (_res_constr.datalen > 0)
7600                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7601         else
7602                 _res_constr.data = NULL;
7603         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7604         for (size_t k = 0; k < _res_constr.datalen; k++) {
7605                 uint32_t _res_conv_10 = _res_vals[k];
7606                 LDKRouteHop _res_conv_10_conv;
7607                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7608                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7609                 _res_constr.data[k] = _res_conv_10_conv;
7610         }
7611         CVec_RouteHopZ_free(_res_constr);
7612 }
7613
7614 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7615         LDKCVec_CVec_RouteHopZZ _res_constr;
7616         _res_constr.datalen = *((uint32_t*)_res);
7617         if (_res_constr.datalen > 0)
7618                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7619         else
7620                 _res_constr.data = NULL;
7621         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7622         for (size_t m = 0; m < _res_constr.datalen; m++) {
7623                 uint32_tArray _res_conv_12 = _res_vals[m];
7624                 LDKCVec_RouteHopZ _res_conv_12_constr;
7625                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7626                 if (_res_conv_12_constr.datalen > 0)
7627                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7628                 else
7629                         _res_conv_12_constr.data = NULL;
7630                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7631                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7632                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7633                         LDKRouteHop _res_conv_12_conv_10_conv;
7634                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7635                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7636                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7637                 }
7638                 _res_constr.data[m] = _res_conv_12_constr;
7639         }
7640         CVec_CVec_RouteHopZZ_free(_res_constr);
7641 }
7642
7643 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7644         LDKRoute o_conv;
7645         o_conv.inner = (void*)(o & (~1));
7646         o_conv.is_owned = (o & 1) || (o == 0);
7647         o_conv = Route_clone(&o_conv);
7648         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7649         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7650         return (long)ret_conv;
7651 }
7652
7653 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7654         LDKDecodeError e_conv;
7655         e_conv.inner = (void*)(e & (~1));
7656         e_conv.is_owned = (e & 1) || (e == 0);
7657         e_conv = DecodeError_clone(&e_conv);
7658         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7659         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7660         return (long)ret_conv;
7661 }
7662
7663 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7664         if ((_res & 1) != 0) return;
7665         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7666         FREE((void*)_res);
7667         CResult_RouteDecodeErrorZ_free(_res_conv);
7668 }
7669
7670 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7671         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7672         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7673         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7674         return (long)ret_conv;
7675 }
7676
7677 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7678         LDKCVec_RouteHintZ _res_constr;
7679         _res_constr.datalen = *((uint32_t*)_res);
7680         if (_res_constr.datalen > 0)
7681                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7682         else
7683                 _res_constr.data = NULL;
7684         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7685         for (size_t l = 0; l < _res_constr.datalen; l++) {
7686                 uint32_t _res_conv_11 = _res_vals[l];
7687                 LDKRouteHint _res_conv_11_conv;
7688                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7689                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7690                 _res_constr.data[l] = _res_conv_11_conv;
7691         }
7692         CVec_RouteHintZ_free(_res_constr);
7693 }
7694
7695 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7696         LDKRoute o_conv;
7697         o_conv.inner = (void*)(o & (~1));
7698         o_conv.is_owned = (o & 1) || (o == 0);
7699         o_conv = Route_clone(&o_conv);
7700         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7701         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7702         return (long)ret_conv;
7703 }
7704
7705 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7706         LDKLightningError e_conv;
7707         e_conv.inner = (void*)(e & (~1));
7708         e_conv.is_owned = (e & 1) || (e == 0);
7709         e_conv = LightningError_clone(&e_conv);
7710         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7711         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7712         return (long)ret_conv;
7713 }
7714
7715 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7716         if ((_res & 1) != 0) return;
7717         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7718         FREE((void*)_res);
7719         CResult_RouteLightningErrorZ_free(_res_conv);
7720 }
7721
7722 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7723         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7724         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7725         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7726         return (long)ret_conv;
7727 }
7728
7729 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
7730         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
7731         FREE((void*)o);
7732         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7733         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
7734         return (long)ret_conv;
7735 }
7736
7737 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
7738         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7739         *ret_conv = CResult_NetAddressu8Z_err(e);
7740         return (long)ret_conv;
7741 }
7742
7743 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
7744         if ((_res & 1) != 0) return;
7745         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
7746         FREE((void*)_res);
7747         CResult_NetAddressu8Z_free(_res_conv);
7748 }
7749
7750 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
7751         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
7752         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7753         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
7754         return (long)ret_conv;
7755 }
7756
7757 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
7758         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
7759         FREE((void*)o);
7760         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7761         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
7762         return (long)ret_conv;
7763 }
7764
7765 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
7766         LDKDecodeError e_conv;
7767         e_conv.inner = (void*)(e & (~1));
7768         e_conv.is_owned = (e & 1) || (e == 0);
7769         e_conv = DecodeError_clone(&e_conv);
7770         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7771         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
7772         return (long)ret_conv;
7773 }
7774
7775 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
7776         if ((_res & 1) != 0) return;
7777         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7778         FREE((void*)_res);
7779         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
7780 }
7781
7782 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
7783         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
7784         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7785         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
7786         return (long)ret_conv;
7787 }
7788
7789 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
7790         LDKCVec_UpdateAddHTLCZ _res_constr;
7791         _res_constr.datalen = *((uint32_t*)_res);
7792         if (_res_constr.datalen > 0)
7793                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
7794         else
7795                 _res_constr.data = NULL;
7796         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7797         for (size_t p = 0; p < _res_constr.datalen; p++) {
7798                 uint32_t _res_conv_15 = _res_vals[p];
7799                 LDKUpdateAddHTLC _res_conv_15_conv;
7800                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
7801                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
7802                 _res_constr.data[p] = _res_conv_15_conv;
7803         }
7804         CVec_UpdateAddHTLCZ_free(_res_constr);
7805 }
7806
7807 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
7808         LDKCVec_UpdateFulfillHTLCZ _res_constr;
7809         _res_constr.datalen = *((uint32_t*)_res);
7810         if (_res_constr.datalen > 0)
7811                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
7812         else
7813                 _res_constr.data = NULL;
7814         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7815         for (size_t t = 0; t < _res_constr.datalen; t++) {
7816                 uint32_t _res_conv_19 = _res_vals[t];
7817                 LDKUpdateFulfillHTLC _res_conv_19_conv;
7818                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
7819                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
7820                 _res_constr.data[t] = _res_conv_19_conv;
7821         }
7822         CVec_UpdateFulfillHTLCZ_free(_res_constr);
7823 }
7824
7825 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
7826         LDKCVec_UpdateFailHTLCZ _res_constr;
7827         _res_constr.datalen = *((uint32_t*)_res);
7828         if (_res_constr.datalen > 0)
7829                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
7830         else
7831                 _res_constr.data = NULL;
7832         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7833         for (size_t q = 0; q < _res_constr.datalen; q++) {
7834                 uint32_t _res_conv_16 = _res_vals[q];
7835                 LDKUpdateFailHTLC _res_conv_16_conv;
7836                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7837                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7838                 _res_constr.data[q] = _res_conv_16_conv;
7839         }
7840         CVec_UpdateFailHTLCZ_free(_res_constr);
7841 }
7842
7843 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
7844         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
7845         _res_constr.datalen = *((uint32_t*)_res);
7846         if (_res_constr.datalen > 0)
7847                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
7848         else
7849                 _res_constr.data = NULL;
7850         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7851         for (size_t z = 0; z < _res_constr.datalen; z++) {
7852                 uint32_t _res_conv_25 = _res_vals[z];
7853                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
7854                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
7855                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
7856                 _res_constr.data[z] = _res_conv_25_conv;
7857         }
7858         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
7859 }
7860
7861 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
7862         LDKAcceptChannel o_conv;
7863         o_conv.inner = (void*)(o & (~1));
7864         o_conv.is_owned = (o & 1) || (o == 0);
7865         o_conv = AcceptChannel_clone(&o_conv);
7866         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7867         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
7868         return (long)ret_conv;
7869 }
7870
7871 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
7872         LDKDecodeError e_conv;
7873         e_conv.inner = (void*)(e & (~1));
7874         e_conv.is_owned = (e & 1) || (e == 0);
7875         e_conv = DecodeError_clone(&e_conv);
7876         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7877         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
7878         return (long)ret_conv;
7879 }
7880
7881 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
7882         if ((_res & 1) != 0) return;
7883         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7884         FREE((void*)_res);
7885         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
7886 }
7887
7888 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
7889         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
7890         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7891         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
7892         return (long)ret_conv;
7893 }
7894
7895 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
7896         LDKAnnouncementSignatures o_conv;
7897         o_conv.inner = (void*)(o & (~1));
7898         o_conv.is_owned = (o & 1) || (o == 0);
7899         o_conv = AnnouncementSignatures_clone(&o_conv);
7900         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7901         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
7902         return (long)ret_conv;
7903 }
7904
7905 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
7906         LDKDecodeError e_conv;
7907         e_conv.inner = (void*)(e & (~1));
7908         e_conv.is_owned = (e & 1) || (e == 0);
7909         e_conv = DecodeError_clone(&e_conv);
7910         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7911         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
7912         return (long)ret_conv;
7913 }
7914
7915 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
7916         if ((_res & 1) != 0) return;
7917         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7918         FREE((void*)_res);
7919         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
7920 }
7921
7922 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
7923         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
7924         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7925         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
7926         return (long)ret_conv;
7927 }
7928
7929 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
7930         LDKChannelReestablish o_conv;
7931         o_conv.inner = (void*)(o & (~1));
7932         o_conv.is_owned = (o & 1) || (o == 0);
7933         o_conv = ChannelReestablish_clone(&o_conv);
7934         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7935         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
7936         return (long)ret_conv;
7937 }
7938
7939 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
7940         LDKDecodeError e_conv;
7941         e_conv.inner = (void*)(e & (~1));
7942         e_conv.is_owned = (e & 1) || (e == 0);
7943         e_conv = DecodeError_clone(&e_conv);
7944         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7945         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
7946         return (long)ret_conv;
7947 }
7948
7949 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
7950         if ((_res & 1) != 0) return;
7951         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
7952         FREE((void*)_res);
7953         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
7954 }
7955
7956 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
7957         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
7958         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7959         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
7960         return (long)ret_conv;
7961 }
7962
7963 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
7964         LDKClosingSigned o_conv;
7965         o_conv.inner = (void*)(o & (~1));
7966         o_conv.is_owned = (o & 1) || (o == 0);
7967         o_conv = ClosingSigned_clone(&o_conv);
7968         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7969         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
7970         return (long)ret_conv;
7971 }
7972
7973 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
7974         LDKDecodeError e_conv;
7975         e_conv.inner = (void*)(e & (~1));
7976         e_conv.is_owned = (e & 1) || (e == 0);
7977         e_conv = DecodeError_clone(&e_conv);
7978         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7979         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
7980         return (long)ret_conv;
7981 }
7982
7983 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
7984         if ((_res & 1) != 0) return;
7985         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7986         FREE((void*)_res);
7987         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
7988 }
7989
7990 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
7991         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
7992         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7993         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
7994         return (long)ret_conv;
7995 }
7996
7997 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
7998         LDKCommitmentSigned o_conv;
7999         o_conv.inner = (void*)(o & (~1));
8000         o_conv.is_owned = (o & 1) || (o == 0);
8001         o_conv = CommitmentSigned_clone(&o_conv);
8002         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8003         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
8004         return (long)ret_conv;
8005 }
8006
8007 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
8008         LDKDecodeError e_conv;
8009         e_conv.inner = (void*)(e & (~1));
8010         e_conv.is_owned = (e & 1) || (e == 0);
8011         e_conv = DecodeError_clone(&e_conv);
8012         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8013         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
8014         return (long)ret_conv;
8015 }
8016
8017 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
8018         if ((_res & 1) != 0) return;
8019         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8020         FREE((void*)_res);
8021         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
8022 }
8023
8024 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
8025         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
8026         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
8027         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
8028         return (long)ret_conv;
8029 }
8030
8031 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
8032         LDKFundingCreated o_conv;
8033         o_conv.inner = (void*)(o & (~1));
8034         o_conv.is_owned = (o & 1) || (o == 0);
8035         o_conv = FundingCreated_clone(&o_conv);
8036         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8037         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
8038         return (long)ret_conv;
8039 }
8040
8041 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
8042         LDKDecodeError e_conv;
8043         e_conv.inner = (void*)(e & (~1));
8044         e_conv.is_owned = (e & 1) || (e == 0);
8045         e_conv = DecodeError_clone(&e_conv);
8046         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8047         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
8048         return (long)ret_conv;
8049 }
8050
8051 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
8052         if ((_res & 1) != 0) return;
8053         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8054         FREE((void*)_res);
8055         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
8056 }
8057
8058 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
8059         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
8060         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
8061         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
8062         return (long)ret_conv;
8063 }
8064
8065 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
8066         LDKFundingSigned o_conv;
8067         o_conv.inner = (void*)(o & (~1));
8068         o_conv.is_owned = (o & 1) || (o == 0);
8069         o_conv = FundingSigned_clone(&o_conv);
8070         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8071         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
8072         return (long)ret_conv;
8073 }
8074
8075 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
8076         LDKDecodeError e_conv;
8077         e_conv.inner = (void*)(e & (~1));
8078         e_conv.is_owned = (e & 1) || (e == 0);
8079         e_conv = DecodeError_clone(&e_conv);
8080         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8081         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
8082         return (long)ret_conv;
8083 }
8084
8085 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
8086         if ((_res & 1) != 0) return;
8087         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8088         FREE((void*)_res);
8089         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
8090 }
8091
8092 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
8093         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
8094         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
8095         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
8096         return (long)ret_conv;
8097 }
8098
8099 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
8100         LDKFundingLocked o_conv;
8101         o_conv.inner = (void*)(o & (~1));
8102         o_conv.is_owned = (o & 1) || (o == 0);
8103         o_conv = FundingLocked_clone(&o_conv);
8104         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8105         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
8106         return (long)ret_conv;
8107 }
8108
8109 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
8110         LDKDecodeError e_conv;
8111         e_conv.inner = (void*)(e & (~1));
8112         e_conv.is_owned = (e & 1) || (e == 0);
8113         e_conv = DecodeError_clone(&e_conv);
8114         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8115         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
8116         return (long)ret_conv;
8117 }
8118
8119 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
8120         if ((_res & 1) != 0) return;
8121         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
8122         FREE((void*)_res);
8123         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
8124 }
8125
8126 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
8127         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
8128         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
8129         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
8130         return (long)ret_conv;
8131 }
8132
8133 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
8134         LDKInit o_conv;
8135         o_conv.inner = (void*)(o & (~1));
8136         o_conv.is_owned = (o & 1) || (o == 0);
8137         o_conv = Init_clone(&o_conv);
8138         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8139         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
8140         return (long)ret_conv;
8141 }
8142
8143 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
8144         LDKDecodeError e_conv;
8145         e_conv.inner = (void*)(e & (~1));
8146         e_conv.is_owned = (e & 1) || (e == 0);
8147         e_conv = DecodeError_clone(&e_conv);
8148         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8149         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
8150         return (long)ret_conv;
8151 }
8152
8153 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
8154         if ((_res & 1) != 0) return;
8155         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
8156         FREE((void*)_res);
8157         CResult_InitDecodeErrorZ_free(_res_conv);
8158 }
8159
8160 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
8161         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
8162         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
8163         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
8164         return (long)ret_conv;
8165 }
8166
8167 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
8168         LDKOpenChannel o_conv;
8169         o_conv.inner = (void*)(o & (~1));
8170         o_conv.is_owned = (o & 1) || (o == 0);
8171         o_conv = OpenChannel_clone(&o_conv);
8172         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8173         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
8174         return (long)ret_conv;
8175 }
8176
8177 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
8178         LDKDecodeError e_conv;
8179         e_conv.inner = (void*)(e & (~1));
8180         e_conv.is_owned = (e & 1) || (e == 0);
8181         e_conv = DecodeError_clone(&e_conv);
8182         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8183         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
8184         return (long)ret_conv;
8185 }
8186
8187 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
8188         if ((_res & 1) != 0) return;
8189         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
8190         FREE((void*)_res);
8191         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
8192 }
8193
8194 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
8195         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
8196         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8197         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
8198         return (long)ret_conv;
8199 }
8200
8201 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
8202         LDKRevokeAndACK o_conv;
8203         o_conv.inner = (void*)(o & (~1));
8204         o_conv.is_owned = (o & 1) || (o == 0);
8205         o_conv = RevokeAndACK_clone(&o_conv);
8206         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8207         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
8208         return (long)ret_conv;
8209 }
8210
8211 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
8212         LDKDecodeError e_conv;
8213         e_conv.inner = (void*)(e & (~1));
8214         e_conv.is_owned = (e & 1) || (e == 0);
8215         e_conv = DecodeError_clone(&e_conv);
8216         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8217         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
8218         return (long)ret_conv;
8219 }
8220
8221 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
8222         if ((_res & 1) != 0) return;
8223         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
8224         FREE((void*)_res);
8225         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
8226 }
8227
8228 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
8229         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
8230         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8231         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
8232         return (long)ret_conv;
8233 }
8234
8235 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
8236         LDKShutdown o_conv;
8237         o_conv.inner = (void*)(o & (~1));
8238         o_conv.is_owned = (o & 1) || (o == 0);
8239         o_conv = Shutdown_clone(&o_conv);
8240         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8241         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
8242         return (long)ret_conv;
8243 }
8244
8245 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
8246         LDKDecodeError e_conv;
8247         e_conv.inner = (void*)(e & (~1));
8248         e_conv.is_owned = (e & 1) || (e == 0);
8249         e_conv = DecodeError_clone(&e_conv);
8250         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8251         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
8252         return (long)ret_conv;
8253 }
8254
8255 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
8256         if ((_res & 1) != 0) return;
8257         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
8258         FREE((void*)_res);
8259         CResult_ShutdownDecodeErrorZ_free(_res_conv);
8260 }
8261
8262 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
8263         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
8264         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8265         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
8266         return (long)ret_conv;
8267 }
8268
8269 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
8270         LDKUpdateFailHTLC o_conv;
8271         o_conv.inner = (void*)(o & (~1));
8272         o_conv.is_owned = (o & 1) || (o == 0);
8273         o_conv = UpdateFailHTLC_clone(&o_conv);
8274         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8275         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
8276         return (long)ret_conv;
8277 }
8278
8279 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
8280         LDKDecodeError e_conv;
8281         e_conv.inner = (void*)(e & (~1));
8282         e_conv.is_owned = (e & 1) || (e == 0);
8283         e_conv = DecodeError_clone(&e_conv);
8284         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8285         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
8286         return (long)ret_conv;
8287 }
8288
8289 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
8290         if ((_res & 1) != 0) return;
8291         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8292         FREE((void*)_res);
8293         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
8294 }
8295
8296 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
8297         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
8298         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8299         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
8300         return (long)ret_conv;
8301 }
8302
8303 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
8304         LDKUpdateFailMalformedHTLC o_conv;
8305         o_conv.inner = (void*)(o & (~1));
8306         o_conv.is_owned = (o & 1) || (o == 0);
8307         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
8308         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8309         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
8310         return (long)ret_conv;
8311 }
8312
8313 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
8314         LDKDecodeError e_conv;
8315         e_conv.inner = (void*)(e & (~1));
8316         e_conv.is_owned = (e & 1) || (e == 0);
8317         e_conv = DecodeError_clone(&e_conv);
8318         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8319         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
8320         return (long)ret_conv;
8321 }
8322
8323 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
8324         if ((_res & 1) != 0) return;
8325         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8326         FREE((void*)_res);
8327         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
8328 }
8329
8330 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
8331         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
8332         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8333         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
8334         return (long)ret_conv;
8335 }
8336
8337 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
8338         LDKUpdateFee o_conv;
8339         o_conv.inner = (void*)(o & (~1));
8340         o_conv.is_owned = (o & 1) || (o == 0);
8341         o_conv = UpdateFee_clone(&o_conv);
8342         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8343         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
8344         return (long)ret_conv;
8345 }
8346
8347 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
8348         LDKDecodeError e_conv;
8349         e_conv.inner = (void*)(e & (~1));
8350         e_conv.is_owned = (e & 1) || (e == 0);
8351         e_conv = DecodeError_clone(&e_conv);
8352         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8353         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
8354         return (long)ret_conv;
8355 }
8356
8357 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
8358         if ((_res & 1) != 0) return;
8359         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8360         FREE((void*)_res);
8361         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
8362 }
8363
8364 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
8365         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
8366         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8367         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
8368         return (long)ret_conv;
8369 }
8370
8371 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
8372         LDKUpdateFulfillHTLC o_conv;
8373         o_conv.inner = (void*)(o & (~1));
8374         o_conv.is_owned = (o & 1) || (o == 0);
8375         o_conv = UpdateFulfillHTLC_clone(&o_conv);
8376         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8377         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
8378         return (long)ret_conv;
8379 }
8380
8381 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
8382         LDKDecodeError e_conv;
8383         e_conv.inner = (void*)(e & (~1));
8384         e_conv.is_owned = (e & 1) || (e == 0);
8385         e_conv = DecodeError_clone(&e_conv);
8386         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8387         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
8388         return (long)ret_conv;
8389 }
8390
8391 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
8392         if ((_res & 1) != 0) return;
8393         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8394         FREE((void*)_res);
8395         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
8396 }
8397
8398 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
8399         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
8400         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8401         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
8402         return (long)ret_conv;
8403 }
8404
8405 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
8406         LDKUpdateAddHTLC o_conv;
8407         o_conv.inner = (void*)(o & (~1));
8408         o_conv.is_owned = (o & 1) || (o == 0);
8409         o_conv = UpdateAddHTLC_clone(&o_conv);
8410         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8411         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
8412         return (long)ret_conv;
8413 }
8414
8415 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
8416         LDKDecodeError e_conv;
8417         e_conv.inner = (void*)(e & (~1));
8418         e_conv.is_owned = (e & 1) || (e == 0);
8419         e_conv = DecodeError_clone(&e_conv);
8420         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8421         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
8422         return (long)ret_conv;
8423 }
8424
8425 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
8426         if ((_res & 1) != 0) return;
8427         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8428         FREE((void*)_res);
8429         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
8430 }
8431
8432 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
8433         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
8434         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8435         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
8436         return (long)ret_conv;
8437 }
8438
8439 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
8440         LDKPing o_conv;
8441         o_conv.inner = (void*)(o & (~1));
8442         o_conv.is_owned = (o & 1) || (o == 0);
8443         o_conv = Ping_clone(&o_conv);
8444         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8445         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
8446         return (long)ret_conv;
8447 }
8448
8449 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
8450         LDKDecodeError e_conv;
8451         e_conv.inner = (void*)(e & (~1));
8452         e_conv.is_owned = (e & 1) || (e == 0);
8453         e_conv = DecodeError_clone(&e_conv);
8454         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8455         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
8456         return (long)ret_conv;
8457 }
8458
8459 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
8460         if ((_res & 1) != 0) return;
8461         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
8462         FREE((void*)_res);
8463         CResult_PingDecodeErrorZ_free(_res_conv);
8464 }
8465
8466 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
8467         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
8468         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8469         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
8470         return (long)ret_conv;
8471 }
8472
8473 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
8474         LDKPong o_conv;
8475         o_conv.inner = (void*)(o & (~1));
8476         o_conv.is_owned = (o & 1) || (o == 0);
8477         o_conv = Pong_clone(&o_conv);
8478         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8479         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
8480         return (long)ret_conv;
8481 }
8482
8483 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
8484         LDKDecodeError e_conv;
8485         e_conv.inner = (void*)(e & (~1));
8486         e_conv.is_owned = (e & 1) || (e == 0);
8487         e_conv = DecodeError_clone(&e_conv);
8488         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8489         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
8490         return (long)ret_conv;
8491 }
8492
8493 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
8494         if ((_res & 1) != 0) return;
8495         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
8496         FREE((void*)_res);
8497         CResult_PongDecodeErrorZ_free(_res_conv);
8498 }
8499
8500 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
8501         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
8502         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8503         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
8504         return (long)ret_conv;
8505 }
8506
8507 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8508         LDKUnsignedChannelAnnouncement o_conv;
8509         o_conv.inner = (void*)(o & (~1));
8510         o_conv.is_owned = (o & 1) || (o == 0);
8511         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
8512         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8513         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
8514         return (long)ret_conv;
8515 }
8516
8517 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8518         LDKDecodeError e_conv;
8519         e_conv.inner = (void*)(e & (~1));
8520         e_conv.is_owned = (e & 1) || (e == 0);
8521         e_conv = DecodeError_clone(&e_conv);
8522         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8523         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
8524         return (long)ret_conv;
8525 }
8526
8527 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8528         if ((_res & 1) != 0) return;
8529         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8530         FREE((void*)_res);
8531         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
8532 }
8533
8534 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8535         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8536         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8537         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8538         return (long)ret_conv;
8539 }
8540
8541 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8542         LDKChannelAnnouncement o_conv;
8543         o_conv.inner = (void*)(o & (~1));
8544         o_conv.is_owned = (o & 1) || (o == 0);
8545         o_conv = ChannelAnnouncement_clone(&o_conv);
8546         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8547         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
8548         return (long)ret_conv;
8549 }
8550
8551 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8552         LDKDecodeError e_conv;
8553         e_conv.inner = (void*)(e & (~1));
8554         e_conv.is_owned = (e & 1) || (e == 0);
8555         e_conv = DecodeError_clone(&e_conv);
8556         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8557         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
8558         return (long)ret_conv;
8559 }
8560
8561 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8562         if ((_res & 1) != 0) return;
8563         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8564         FREE((void*)_res);
8565         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
8566 }
8567
8568 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8569         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8570         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8571         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8572         return (long)ret_conv;
8573 }
8574
8575 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8576         LDKUnsignedChannelUpdate o_conv;
8577         o_conv.inner = (void*)(o & (~1));
8578         o_conv.is_owned = (o & 1) || (o == 0);
8579         o_conv = UnsignedChannelUpdate_clone(&o_conv);
8580         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8581         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
8582         return (long)ret_conv;
8583 }
8584
8585 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
8586         LDKDecodeError e_conv;
8587         e_conv.inner = (void*)(e & (~1));
8588         e_conv.is_owned = (e & 1) || (e == 0);
8589         e_conv = DecodeError_clone(&e_conv);
8590         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8591         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
8592         return (long)ret_conv;
8593 }
8594
8595 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8596         if ((_res & 1) != 0) return;
8597         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8598         FREE((void*)_res);
8599         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
8600 }
8601
8602 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8603         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
8604         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8605         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
8606         return (long)ret_conv;
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8610         LDKChannelUpdate o_conv;
8611         o_conv.inner = (void*)(o & (~1));
8612         o_conv.is_owned = (o & 1) || (o == 0);
8613         o_conv = ChannelUpdate_clone(&o_conv);
8614         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8615         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
8616         return (long)ret_conv;
8617 }
8618
8619 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
8620         LDKDecodeError e_conv;
8621         e_conv.inner = (void*)(e & (~1));
8622         e_conv.is_owned = (e & 1) || (e == 0);
8623         e_conv = DecodeError_clone(&e_conv);
8624         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8625         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
8626         return (long)ret_conv;
8627 }
8628
8629 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8630         if ((_res & 1) != 0) return;
8631         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8632         FREE((void*)_res);
8633         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
8634 }
8635
8636 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8637         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
8638         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8639         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
8640         return (long)ret_conv;
8641 }
8642
8643 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
8644         LDKErrorMessage o_conv;
8645         o_conv.inner = (void*)(o & (~1));
8646         o_conv.is_owned = (o & 1) || (o == 0);
8647         o_conv = ErrorMessage_clone(&o_conv);
8648         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8649         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
8650         return (long)ret_conv;
8651 }
8652
8653 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
8654         LDKDecodeError e_conv;
8655         e_conv.inner = (void*)(e & (~1));
8656         e_conv.is_owned = (e & 1) || (e == 0);
8657         e_conv = DecodeError_clone(&e_conv);
8658         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8659         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
8660         return (long)ret_conv;
8661 }
8662
8663 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
8664         if ((_res & 1) != 0) return;
8665         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
8666         FREE((void*)_res);
8667         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
8668 }
8669
8670 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
8671         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
8672         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8673         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
8674         return (long)ret_conv;
8675 }
8676
8677 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8678         LDKUnsignedNodeAnnouncement o_conv;
8679         o_conv.inner = (void*)(o & (~1));
8680         o_conv.is_owned = (o & 1) || (o == 0);
8681         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
8682         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8683         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
8684         return (long)ret_conv;
8685 }
8686
8687 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8688         LDKDecodeError e_conv;
8689         e_conv.inner = (void*)(e & (~1));
8690         e_conv.is_owned = (e & 1) || (e == 0);
8691         e_conv = DecodeError_clone(&e_conv);
8692         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8693         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
8694         return (long)ret_conv;
8695 }
8696
8697 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8698         if ((_res & 1) != 0) return;
8699         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8700         FREE((void*)_res);
8701         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
8702 }
8703
8704 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8705         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
8706         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8707         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
8708         return (long)ret_conv;
8709 }
8710
8711 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8712         LDKNodeAnnouncement o_conv;
8713         o_conv.inner = (void*)(o & (~1));
8714         o_conv.is_owned = (o & 1) || (o == 0);
8715         o_conv = NodeAnnouncement_clone(&o_conv);
8716         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8717         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
8718         return (long)ret_conv;
8719 }
8720
8721 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8722         LDKDecodeError e_conv;
8723         e_conv.inner = (void*)(e & (~1));
8724         e_conv.is_owned = (e & 1) || (e == 0);
8725         e_conv = DecodeError_clone(&e_conv);
8726         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8727         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
8728         return (long)ret_conv;
8729 }
8730
8731 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8732         if ((_res & 1) != 0) return;
8733         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8734         FREE((void*)_res);
8735         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
8736 }
8737
8738 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8739         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
8740         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8741         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
8742         return (long)ret_conv;
8743 }
8744
8745 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
8746         LDKQueryShortChannelIds o_conv;
8747         o_conv.inner = (void*)(o & (~1));
8748         o_conv.is_owned = (o & 1) || (o == 0);
8749         o_conv = QueryShortChannelIds_clone(&o_conv);
8750         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8751         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
8752         return (long)ret_conv;
8753 }
8754
8755 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
8756         LDKDecodeError e_conv;
8757         e_conv.inner = (void*)(e & (~1));
8758         e_conv.is_owned = (e & 1) || (e == 0);
8759         e_conv = DecodeError_clone(&e_conv);
8760         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8761         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
8762         return (long)ret_conv;
8763 }
8764
8765 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
8766         if ((_res & 1) != 0) return;
8767         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
8768         FREE((void*)_res);
8769         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
8770 }
8771
8772 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
8773         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
8774         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8775         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
8776         return (long)ret_conv;
8777 }
8778
8779 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
8780         LDKReplyShortChannelIdsEnd o_conv;
8781         o_conv.inner = (void*)(o & (~1));
8782         o_conv.is_owned = (o & 1) || (o == 0);
8783         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
8784         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8785         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
8786         return (long)ret_conv;
8787 }
8788
8789 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
8790         LDKDecodeError e_conv;
8791         e_conv.inner = (void*)(e & (~1));
8792         e_conv.is_owned = (e & 1) || (e == 0);
8793         e_conv = DecodeError_clone(&e_conv);
8794         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8795         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
8796         return (long)ret_conv;
8797 }
8798
8799 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
8800         if ((_res & 1) != 0) return;
8801         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
8802         FREE((void*)_res);
8803         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
8804 }
8805
8806 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
8807         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
8808         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8809         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
8810         return (long)ret_conv;
8811 }
8812
8813 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
8814         LDKQueryChannelRange o_conv;
8815         o_conv.inner = (void*)(o & (~1));
8816         o_conv.is_owned = (o & 1) || (o == 0);
8817         o_conv = QueryChannelRange_clone(&o_conv);
8818         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8819         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
8820         return (long)ret_conv;
8821 }
8822
8823 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
8824         LDKDecodeError e_conv;
8825         e_conv.inner = (void*)(e & (~1));
8826         e_conv.is_owned = (e & 1) || (e == 0);
8827         e_conv = DecodeError_clone(&e_conv);
8828         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8829         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
8830         return (long)ret_conv;
8831 }
8832
8833 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
8834         if ((_res & 1) != 0) return;
8835         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8836         FREE((void*)_res);
8837         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
8838 }
8839
8840 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8841         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
8842         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8843         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
8844         return (long)ret_conv;
8845 }
8846
8847 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
8848         LDKReplyChannelRange o_conv;
8849         o_conv.inner = (void*)(o & (~1));
8850         o_conv.is_owned = (o & 1) || (o == 0);
8851         o_conv = ReplyChannelRange_clone(&o_conv);
8852         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8853         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
8854         return (long)ret_conv;
8855 }
8856
8857 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
8858         LDKDecodeError e_conv;
8859         e_conv.inner = (void*)(e & (~1));
8860         e_conv.is_owned = (e & 1) || (e == 0);
8861         e_conv = DecodeError_clone(&e_conv);
8862         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8863         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
8864         return (long)ret_conv;
8865 }
8866
8867 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
8868         if ((_res & 1) != 0) return;
8869         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8870         FREE((void*)_res);
8871         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
8872 }
8873
8874 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8875         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
8876         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8877         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
8878         return (long)ret_conv;
8879 }
8880
8881 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
8882         LDKGossipTimestampFilter o_conv;
8883         o_conv.inner = (void*)(o & (~1));
8884         o_conv.is_owned = (o & 1) || (o == 0);
8885         o_conv = GossipTimestampFilter_clone(&o_conv);
8886         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8887         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
8888         return (long)ret_conv;
8889 }
8890
8891 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
8892         LDKDecodeError e_conv;
8893         e_conv.inner = (void*)(e & (~1));
8894         e_conv.is_owned = (e & 1) || (e == 0);
8895         e_conv = DecodeError_clone(&e_conv);
8896         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8897         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
8898         return (long)ret_conv;
8899 }
8900
8901 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
8902         if ((_res & 1) != 0) return;
8903         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
8904         FREE((void*)_res);
8905         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
8906 }
8907
8908 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
8909         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
8910         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8911         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
8912         return (long)ret_conv;
8913 }
8914
8915 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
8916         if ((this_ptr & 1) != 0) return;
8917         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
8918         FREE((void*)this_ptr);
8919         Event_free(this_ptr_conv);
8920 }
8921
8922 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
8923         LDKEvent* orig_conv = (LDKEvent*)orig;
8924         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
8925         *ret_copy = Event_clone(orig_conv);
8926         long ret_ref = (long)ret_copy;
8927         return ret_ref;
8928 }
8929
8930 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
8931         LDKEvent* obj_conv = (LDKEvent*)obj;
8932         LDKCVec_u8Z ret_var = Event_write(obj_conv);
8933         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8934         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
8935         CVec_u8Z_free(ret_var);
8936         return ret_arr;
8937 }
8938
8939 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
8940         if ((this_ptr & 1) != 0) return;
8941         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
8942         FREE((void*)this_ptr);
8943         MessageSendEvent_free(this_ptr_conv);
8944 }
8945
8946 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
8947         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
8948         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8949         *ret_copy = MessageSendEvent_clone(orig_conv);
8950         long ret_ref = (long)ret_copy;
8951         return ret_ref;
8952 }
8953
8954 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
8955         if ((this_ptr & 1) != 0) return;
8956         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
8957         FREE((void*)this_ptr);
8958         MessageSendEventsProvider_free(this_ptr_conv);
8959 }
8960
8961 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
8962         if ((this_ptr & 1) != 0) return;
8963         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
8964         FREE((void*)this_ptr);
8965         EventsProvider_free(this_ptr_conv);
8966 }
8967
8968 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
8969         if ((this_ptr & 1) != 0) return;
8970         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
8971         FREE((void*)this_ptr);
8972         APIError_free(this_ptr_conv);
8973 }
8974
8975 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
8976         LDKAPIError* orig_conv = (LDKAPIError*)orig;
8977         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
8978         *ret_copy = APIError_clone(orig_conv);
8979         long ret_ref = (long)ret_copy;
8980         return ret_ref;
8981 }
8982
8983 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
8984         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
8985         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
8986         return ret_conv;
8987 }
8988
8989 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
8990         uint32_t ret_conv = LDKLevel_to_js(Level_max());
8991         return ret_conv;
8992 }
8993
8994 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
8995         if ((this_ptr & 1) != 0) return;
8996         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
8997         FREE((void*)this_ptr);
8998         Logger_free(this_ptr_conv);
8999 }
9000
9001 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
9002         LDKChannelHandshakeConfig this_obj_conv;
9003         this_obj_conv.inner = (void*)(this_obj & (~1));
9004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9005         ChannelHandshakeConfig_free(this_obj_conv);
9006 }
9007
9008 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
9009         LDKChannelHandshakeConfig this_ptr_conv;
9010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9011         this_ptr_conv.is_owned = false;
9012         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
9013         return ret_val;
9014 }
9015
9016 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
9017         LDKChannelHandshakeConfig this_ptr_conv;
9018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9019         this_ptr_conv.is_owned = false;
9020         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
9021 }
9022
9023 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
9024         LDKChannelHandshakeConfig this_ptr_conv;
9025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9026         this_ptr_conv.is_owned = false;
9027         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
9028         return ret_val;
9029 }
9030
9031 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
9032         LDKChannelHandshakeConfig this_ptr_conv;
9033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9034         this_ptr_conv.is_owned = false;
9035         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
9036 }
9037
9038 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
9039         LDKChannelHandshakeConfig this_ptr_conv;
9040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9041         this_ptr_conv.is_owned = false;
9042         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
9043         return ret_val;
9044 }
9045
9046 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9047         LDKChannelHandshakeConfig this_ptr_conv;
9048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9049         this_ptr_conv.is_owned = false;
9050         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
9051 }
9052
9053 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
9054         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
9055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9057         long ret_ref = (long)ret_var.inner;
9058         if (ret_var.is_owned) {
9059                 ret_ref |= 1;
9060         }
9061         return ret_ref;
9062 }
9063
9064 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
9065         LDKChannelHandshakeConfig orig_conv;
9066         orig_conv.inner = (void*)(orig & (~1));
9067         orig_conv.is_owned = false;
9068         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
9069         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9070         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9071         long ret_ref = (long)ret_var.inner;
9072         if (ret_var.is_owned) {
9073                 ret_ref |= 1;
9074         }
9075         return ret_ref;
9076 }
9077
9078 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
9079         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
9080         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9081         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9082         long ret_ref = (long)ret_var.inner;
9083         if (ret_var.is_owned) {
9084                 ret_ref |= 1;
9085         }
9086         return ret_ref;
9087 }
9088
9089 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
9090         LDKChannelHandshakeLimits this_obj_conv;
9091         this_obj_conv.inner = (void*)(this_obj & (~1));
9092         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9093         ChannelHandshakeLimits_free(this_obj_conv);
9094 }
9095
9096 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
9097         LDKChannelHandshakeLimits this_ptr_conv;
9098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9099         this_ptr_conv.is_owned = false;
9100         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
9101         return ret_val;
9102 }
9103
9104 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
9105         LDKChannelHandshakeLimits this_ptr_conv;
9106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9107         this_ptr_conv.is_owned = false;
9108         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
9109 }
9110
9111 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
9112         LDKChannelHandshakeLimits this_ptr_conv;
9113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9114         this_ptr_conv.is_owned = false;
9115         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
9116         return ret_val;
9117 }
9118
9119 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9120         LDKChannelHandshakeLimits this_ptr_conv;
9121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9122         this_ptr_conv.is_owned = false;
9123         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
9124 }
9125
9126 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
9127         LDKChannelHandshakeLimits this_ptr_conv;
9128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9129         this_ptr_conv.is_owned = false;
9130         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
9131         return ret_val;
9132 }
9133
9134 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
9135         LDKChannelHandshakeLimits this_ptr_conv;
9136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9137         this_ptr_conv.is_owned = false;
9138         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9139 }
9140
9141 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
9142         LDKChannelHandshakeLimits this_ptr_conv;
9143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9144         this_ptr_conv.is_owned = false;
9145         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
9146         return ret_val;
9147 }
9148
9149 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
9150         LDKChannelHandshakeLimits this_ptr_conv;
9151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9152         this_ptr_conv.is_owned = false;
9153         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
9154 }
9155
9156 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
9157         LDKChannelHandshakeLimits this_ptr_conv;
9158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9159         this_ptr_conv.is_owned = false;
9160         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
9161         return ret_val;
9162 }
9163
9164 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
9165         LDKChannelHandshakeLimits this_ptr_conv;
9166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9167         this_ptr_conv.is_owned = false;
9168         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
9169 }
9170
9171 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
9172         LDKChannelHandshakeLimits this_ptr_conv;
9173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9174         this_ptr_conv.is_owned = false;
9175         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
9176         return ret_val;
9177 }
9178
9179 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
9180         LDKChannelHandshakeLimits this_ptr_conv;
9181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9182         this_ptr_conv.is_owned = false;
9183         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
9184 }
9185
9186 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
9187         LDKChannelHandshakeLimits this_ptr_conv;
9188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9189         this_ptr_conv.is_owned = false;
9190         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
9191         return ret_val;
9192 }
9193
9194 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
9195         LDKChannelHandshakeLimits this_ptr_conv;
9196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9197         this_ptr_conv.is_owned = false;
9198         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
9199 }
9200
9201 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
9202         LDKChannelHandshakeLimits this_ptr_conv;
9203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9204         this_ptr_conv.is_owned = false;
9205         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
9206         return ret_val;
9207 }
9208
9209 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
9210         LDKChannelHandshakeLimits this_ptr_conv;
9211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9212         this_ptr_conv.is_owned = false;
9213         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
9214 }
9215
9216 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
9217         LDKChannelHandshakeLimits this_ptr_conv;
9218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9219         this_ptr_conv.is_owned = false;
9220         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
9221         return ret_val;
9222 }
9223
9224 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
9225         LDKChannelHandshakeLimits this_ptr_conv;
9226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9227         this_ptr_conv.is_owned = false;
9228         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
9229 }
9230
9231 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
9232         LDKChannelHandshakeLimits this_ptr_conv;
9233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9234         this_ptr_conv.is_owned = false;
9235         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
9236         return ret_val;
9237 }
9238
9239 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
9240         LDKChannelHandshakeLimits this_ptr_conv;
9241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9242         this_ptr_conv.is_owned = false;
9243         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
9244 }
9245
9246 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(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) {
9247         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);
9248         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9249         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9250         long ret_ref = (long)ret_var.inner;
9251         if (ret_var.is_owned) {
9252                 ret_ref |= 1;
9253         }
9254         return ret_ref;
9255 }
9256
9257 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
9258         LDKChannelHandshakeLimits orig_conv;
9259         orig_conv.inner = (void*)(orig & (~1));
9260         orig_conv.is_owned = false;
9261         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
9262         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9263         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9264         long ret_ref = (long)ret_var.inner;
9265         if (ret_var.is_owned) {
9266                 ret_ref |= 1;
9267         }
9268         return ret_ref;
9269 }
9270
9271 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
9272         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
9273         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9274         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9275         long ret_ref = (long)ret_var.inner;
9276         if (ret_var.is_owned) {
9277                 ret_ref |= 1;
9278         }
9279         return ret_ref;
9280 }
9281
9282 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
9283         LDKChannelConfig this_obj_conv;
9284         this_obj_conv.inner = (void*)(this_obj & (~1));
9285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9286         ChannelConfig_free(this_obj_conv);
9287 }
9288
9289 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
9290         LDKChannelConfig this_ptr_conv;
9291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9292         this_ptr_conv.is_owned = false;
9293         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
9294         return ret_val;
9295 }
9296
9297 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
9298         LDKChannelConfig this_ptr_conv;
9299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9300         this_ptr_conv.is_owned = false;
9301         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
9302 }
9303
9304 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
9305         LDKChannelConfig this_ptr_conv;
9306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9307         this_ptr_conv.is_owned = false;
9308         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
9309         return ret_val;
9310 }
9311
9312 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
9313         LDKChannelConfig this_ptr_conv;
9314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9315         this_ptr_conv.is_owned = false;
9316         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
9317 }
9318
9319 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
9320         LDKChannelConfig this_ptr_conv;
9321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9322         this_ptr_conv.is_owned = false;
9323         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
9324         return ret_val;
9325 }
9326
9327 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
9328         LDKChannelConfig this_ptr_conv;
9329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9330         this_ptr_conv.is_owned = false;
9331         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
9332 }
9333
9334 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
9335         LDKChannelConfig this_ptr_conv;
9336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9337         this_ptr_conv.is_owned = false;
9338         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
9339         return ret_val;
9340 }
9341
9342 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
9343         LDKChannelConfig this_ptr_conv;
9344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9345         this_ptr_conv.is_owned = false;
9346         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
9347 }
9348
9349 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
9350         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
9351         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9352         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9353         long ret_ref = (long)ret_var.inner;
9354         if (ret_var.is_owned) {
9355                 ret_ref |= 1;
9356         }
9357         return ret_ref;
9358 }
9359
9360 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
9361         LDKChannelConfig orig_conv;
9362         orig_conv.inner = (void*)(orig & (~1));
9363         orig_conv.is_owned = false;
9364         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
9365         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9366         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9367         long ret_ref = (long)ret_var.inner;
9368         if (ret_var.is_owned) {
9369                 ret_ref |= 1;
9370         }
9371         return ret_ref;
9372 }
9373
9374 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
9375         LDKChannelConfig ret_var = ChannelConfig_default();
9376         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9377         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9378         long ret_ref = (long)ret_var.inner;
9379         if (ret_var.is_owned) {
9380                 ret_ref |= 1;
9381         }
9382         return ret_ref;
9383 }
9384
9385 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
9386         LDKChannelConfig obj_conv;
9387         obj_conv.inner = (void*)(obj & (~1));
9388         obj_conv.is_owned = false;
9389         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
9390         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9391         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9392         CVec_u8Z_free(ret_var);
9393         return ret_arr;
9394 }
9395
9396 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
9397         LDKu8slice ser_ref;
9398         ser_ref.datalen = *((uint32_t*)ser);
9399         ser_ref.data = (int8_t*)(ser + 4);
9400         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9401         *ret_conv = ChannelConfig_read(ser_ref);
9402         return (long)ret_conv;
9403 }
9404
9405 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
9406         LDKUserConfig this_obj_conv;
9407         this_obj_conv.inner = (void*)(this_obj & (~1));
9408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9409         UserConfig_free(this_obj_conv);
9410 }
9411
9412 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
9413         LDKUserConfig this_ptr_conv;
9414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9415         this_ptr_conv.is_owned = false;
9416         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
9417         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9418         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9419         long ret_ref = (long)ret_var.inner;
9420         if (ret_var.is_owned) {
9421                 ret_ref |= 1;
9422         }
9423         return ret_ref;
9424 }
9425
9426 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
9427         LDKUserConfig this_ptr_conv;
9428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9429         this_ptr_conv.is_owned = false;
9430         LDKChannelHandshakeConfig val_conv;
9431         val_conv.inner = (void*)(val & (~1));
9432         val_conv.is_owned = (val & 1) || (val == 0);
9433         val_conv = ChannelHandshakeConfig_clone(&val_conv);
9434         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
9435 }
9436
9437 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
9438         LDKUserConfig this_ptr_conv;
9439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9440         this_ptr_conv.is_owned = false;
9441         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
9442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9444         long ret_ref = (long)ret_var.inner;
9445         if (ret_var.is_owned) {
9446                 ret_ref |= 1;
9447         }
9448         return ret_ref;
9449 }
9450
9451 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
9452         LDKUserConfig this_ptr_conv;
9453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9454         this_ptr_conv.is_owned = false;
9455         LDKChannelHandshakeLimits val_conv;
9456         val_conv.inner = (void*)(val & (~1));
9457         val_conv.is_owned = (val & 1) || (val == 0);
9458         val_conv = ChannelHandshakeLimits_clone(&val_conv);
9459         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
9460 }
9461
9462 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
9463         LDKUserConfig this_ptr_conv;
9464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9465         this_ptr_conv.is_owned = false;
9466         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
9467         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9468         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9469         long ret_ref = (long)ret_var.inner;
9470         if (ret_var.is_owned) {
9471                 ret_ref |= 1;
9472         }
9473         return ret_ref;
9474 }
9475
9476 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
9477         LDKUserConfig this_ptr_conv;
9478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9479         this_ptr_conv.is_owned = false;
9480         LDKChannelConfig val_conv;
9481         val_conv.inner = (void*)(val & (~1));
9482         val_conv.is_owned = (val & 1) || (val == 0);
9483         val_conv = ChannelConfig_clone(&val_conv);
9484         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
9485 }
9486
9487 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg) {
9488         LDKChannelHandshakeConfig own_channel_config_arg_conv;
9489         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
9490         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
9491         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
9492         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
9493         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
9494         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
9495         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
9496         LDKChannelConfig channel_options_arg_conv;
9497         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
9498         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
9499         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
9500         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
9501         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9502         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9503         long ret_ref = (long)ret_var.inner;
9504         if (ret_var.is_owned) {
9505                 ret_ref |= 1;
9506         }
9507         return ret_ref;
9508 }
9509
9510 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
9511         LDKUserConfig orig_conv;
9512         orig_conv.inner = (void*)(orig & (~1));
9513         orig_conv.is_owned = false;
9514         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
9515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9517         long ret_ref = (long)ret_var.inner;
9518         if (ret_var.is_owned) {
9519                 ret_ref |= 1;
9520         }
9521         return ret_ref;
9522 }
9523
9524 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
9525         LDKUserConfig ret_var = UserConfig_default();
9526         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9527         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9528         long ret_ref = (long)ret_var.inner;
9529         if (ret_var.is_owned) {
9530                 ret_ref |= 1;
9531         }
9532         return ret_ref;
9533 }
9534
9535 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
9536         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
9537         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
9538         return ret_conv;
9539 }
9540
9541 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
9542         if ((this_ptr & 1) != 0) return;
9543         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
9544         FREE((void*)this_ptr);
9545         Access_free(this_ptr_conv);
9546 }
9547
9548 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
9549         if ((this_ptr & 1) != 0) return;
9550         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
9551         FREE((void*)this_ptr);
9552         Listen_free(this_ptr_conv);
9553 }
9554
9555 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
9556         if ((this_ptr & 1) != 0) return;
9557         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
9558         FREE((void*)this_ptr);
9559         Watch_free(this_ptr_conv);
9560 }
9561
9562 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
9563         if ((this_ptr & 1) != 0) return;
9564         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
9565         FREE((void*)this_ptr);
9566         Filter_free(this_ptr_conv);
9567 }
9568
9569 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
9570         LDKWatchedOutput this_obj_conv;
9571         this_obj_conv.inner = (void*)(this_obj & (~1));
9572         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9573         WatchedOutput_free(this_obj_conv);
9574 }
9575
9576 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
9577         LDKWatchedOutput this_ptr_conv;
9578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9579         this_ptr_conv.is_owned = false;
9580         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9581         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
9582         return ret_arr;
9583 }
9584
9585 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
9586         LDKWatchedOutput this_ptr_conv;
9587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9588         this_ptr_conv.is_owned = false;
9589         LDKThirtyTwoBytes val_ref;
9590         CHECK(*((uint32_t*)val) == 32);
9591         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9592         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
9593 }
9594
9595 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
9596         LDKWatchedOutput this_ptr_conv;
9597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9598         this_ptr_conv.is_owned = false;
9599         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
9600         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9601         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9602         long ret_ref = (long)ret_var.inner;
9603         if (ret_var.is_owned) {
9604                 ret_ref |= 1;
9605         }
9606         return ret_ref;
9607 }
9608
9609 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
9610         LDKWatchedOutput this_ptr_conv;
9611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9612         this_ptr_conv.is_owned = false;
9613         LDKOutPoint val_conv;
9614         val_conv.inner = (void*)(val & (~1));
9615         val_conv.is_owned = (val & 1) || (val == 0);
9616         val_conv = OutPoint_clone(&val_conv);
9617         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
9618 }
9619
9620 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
9621         LDKWatchedOutput this_ptr_conv;
9622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9623         this_ptr_conv.is_owned = false;
9624         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
9625         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9626         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9627         return ret_arr;
9628 }
9629
9630 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
9631         LDKWatchedOutput this_ptr_conv;
9632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9633         this_ptr_conv.is_owned = false;
9634         LDKCVec_u8Z val_ref;
9635         val_ref.datalen = *((uint32_t*)val);
9636         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
9637         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
9638         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
9639 }
9640
9641 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
9642         LDKThirtyTwoBytes block_hash_arg_ref;
9643         CHECK(*((uint32_t*)block_hash_arg) == 32);
9644         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
9645         LDKOutPoint outpoint_arg_conv;
9646         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
9647         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
9648         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
9649         LDKCVec_u8Z script_pubkey_arg_ref;
9650         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
9651         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
9652         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
9653         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
9654         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9655         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9656         long ret_ref = (long)ret_var.inner;
9657         if (ret_var.is_owned) {
9658                 ret_ref |= 1;
9659         }
9660         return ret_ref;
9661 }
9662
9663 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
9664         if ((this_ptr & 1) != 0) return;
9665         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
9666         FREE((void*)this_ptr);
9667         BroadcasterInterface_free(this_ptr_conv);
9668 }
9669
9670 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
9671         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
9672         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
9673         return ret_conv;
9674 }
9675
9676 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
9677         if ((this_ptr & 1) != 0) return;
9678         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
9679         FREE((void*)this_ptr);
9680         FeeEstimator_free(this_ptr_conv);
9681 }
9682
9683 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
9684         LDKChainMonitor this_obj_conv;
9685         this_obj_conv.inner = (void*)(this_obj & (~1));
9686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9687         ChainMonitor_free(this_obj_conv);
9688 }
9689
9690 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9691         LDKChainMonitor this_arg_conv;
9692         this_arg_conv.inner = (void*)(this_arg & (~1));
9693         this_arg_conv.is_owned = false;
9694         unsigned char header_arr[80];
9695         CHECK(*((uint32_t*)header) == 80);
9696         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9697         unsigned char (*header_ref)[80] = &header_arr;
9698         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9699         txdata_constr.datalen = *((uint32_t*)txdata);
9700         if (txdata_constr.datalen > 0)
9701                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9702         else
9703                 txdata_constr.data = NULL;
9704         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9705         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9706                 uint32_t txdata_conv_30 = txdata_vals[e];
9707                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9708                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
9709                 txdata_constr.data[e] = txdata_conv_30_conv;
9710         }
9711         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
9712 }
9713
9714 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
9715         LDKChainMonitor this_arg_conv;
9716         this_arg_conv.inner = (void*)(this_arg & (~1));
9717         this_arg_conv.is_owned = false;
9718         unsigned char header_arr[80];
9719         CHECK(*((uint32_t*)header) == 80);
9720         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9721         unsigned char (*header_ref)[80] = &header_arr;
9722         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
9723 }
9724
9725 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
9726         LDKFilter *chain_source_conv_ptr = NULL;
9727         if (chain_source != 0) {
9728                 LDKFilter chain_source_conv;
9729                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
9730                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9731                 *chain_source_conv_ptr = chain_source_conv;
9732         }
9733         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9734         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9735         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
9736         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
9737         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
9738         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9739         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9740         long ret_ref = (long)ret_var.inner;
9741         if (ret_var.is_owned) {
9742                 ret_ref |= 1;
9743         }
9744         return ret_ref;
9745 }
9746
9747 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
9748         LDKChainMonitor this_arg_conv;
9749         this_arg_conv.inner = (void*)(this_arg & (~1));
9750         this_arg_conv.is_owned = false;
9751         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
9752         *ret = ChainMonitor_as_Watch(&this_arg_conv);
9753         return (long)ret;
9754 }
9755
9756 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
9757         LDKChainMonitor this_arg_conv;
9758         this_arg_conv.inner = (void*)(this_arg & (~1));
9759         this_arg_conv.is_owned = false;
9760         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9761         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
9762         return (long)ret;
9763 }
9764
9765 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
9766         LDKChannelMonitorUpdate this_obj_conv;
9767         this_obj_conv.inner = (void*)(this_obj & (~1));
9768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9769         ChannelMonitorUpdate_free(this_obj_conv);
9770 }
9771
9772 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
9773         LDKChannelMonitorUpdate this_ptr_conv;
9774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9775         this_ptr_conv.is_owned = false;
9776         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
9777         return ret_val;
9778 }
9779
9780 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
9781         LDKChannelMonitorUpdate this_ptr_conv;
9782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9783         this_ptr_conv.is_owned = false;
9784         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
9785 }
9786
9787 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
9788         LDKChannelMonitorUpdate orig_conv;
9789         orig_conv.inner = (void*)(orig & (~1));
9790         orig_conv.is_owned = false;
9791         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
9792         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9793         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9794         long ret_ref = (long)ret_var.inner;
9795         if (ret_var.is_owned) {
9796                 ret_ref |= 1;
9797         }
9798         return ret_ref;
9799 }
9800
9801 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
9802         LDKChannelMonitorUpdate obj_conv;
9803         obj_conv.inner = (void*)(obj & (~1));
9804         obj_conv.is_owned = false;
9805         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
9806         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9807         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9808         CVec_u8Z_free(ret_var);
9809         return ret_arr;
9810 }
9811
9812 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
9813         LDKu8slice ser_ref;
9814         ser_ref.datalen = *((uint32_t*)ser);
9815         ser_ref.data = (int8_t*)(ser + 4);
9816         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9817         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
9818         return (long)ret_conv;
9819 }
9820
9821 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
9822         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
9823         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
9824         return ret_conv;
9825 }
9826
9827 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
9828         LDKMonitorUpdateError this_obj_conv;
9829         this_obj_conv.inner = (void*)(this_obj & (~1));
9830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9831         MonitorUpdateError_free(this_obj_conv);
9832 }
9833
9834 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
9835         LDKMonitorUpdateError orig_conv;
9836         orig_conv.inner = (void*)(orig & (~1));
9837         orig_conv.is_owned = false;
9838         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
9839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9841         long ret_ref = (long)ret_var.inner;
9842         if (ret_var.is_owned) {
9843                 ret_ref |= 1;
9844         }
9845         return ret_ref;
9846 }
9847
9848 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
9849         if ((this_ptr & 1) != 0) return;
9850         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
9851         FREE((void*)this_ptr);
9852         MonitorEvent_free(this_ptr_conv);
9853 }
9854
9855 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
9856         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
9857         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
9858         *ret_copy = MonitorEvent_clone(orig_conv);
9859         long ret_ref = (long)ret_copy;
9860         return ret_ref;
9861 }
9862
9863 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
9864         LDKHTLCUpdate this_obj_conv;
9865         this_obj_conv.inner = (void*)(this_obj & (~1));
9866         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9867         HTLCUpdate_free(this_obj_conv);
9868 }
9869
9870 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
9871         LDKHTLCUpdate orig_conv;
9872         orig_conv.inner = (void*)(orig & (~1));
9873         orig_conv.is_owned = false;
9874         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
9875         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9876         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9877         long ret_ref = (long)ret_var.inner;
9878         if (ret_var.is_owned) {
9879                 ret_ref |= 1;
9880         }
9881         return ret_ref;
9882 }
9883
9884 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
9885         LDKHTLCUpdate obj_conv;
9886         obj_conv.inner = (void*)(obj & (~1));
9887         obj_conv.is_owned = false;
9888         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
9889         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9890         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9891         CVec_u8Z_free(ret_var);
9892         return ret_arr;
9893 }
9894
9895 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
9896         LDKu8slice ser_ref;
9897         ser_ref.datalen = *((uint32_t*)ser);
9898         ser_ref.data = (int8_t*)(ser + 4);
9899         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9900         *ret_conv = HTLCUpdate_read(ser_ref);
9901         return (long)ret_conv;
9902 }
9903
9904 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
9905         LDKChannelMonitor this_obj_conv;
9906         this_obj_conv.inner = (void*)(this_obj & (~1));
9907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9908         ChannelMonitor_free(this_obj_conv);
9909 }
9910
9911 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
9912         LDKChannelMonitor orig_conv;
9913         orig_conv.inner = (void*)(orig & (~1));
9914         orig_conv.is_owned = false;
9915         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
9916         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9917         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9918         long ret_ref = (long)ret_var.inner;
9919         if (ret_var.is_owned) {
9920                 ret_ref |= 1;
9921         }
9922         return ret_ref;
9923 }
9924
9925 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
9926         LDKChannelMonitor obj_conv;
9927         obj_conv.inner = (void*)(obj & (~1));
9928         obj_conv.is_owned = false;
9929         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
9930         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9931         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9932         CVec_u8Z_free(ret_var);
9933         return ret_arr;
9934 }
9935
9936 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_update_monitor(uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
9937         LDKChannelMonitor this_arg_conv;
9938         this_arg_conv.inner = (void*)(this_arg & (~1));
9939         this_arg_conv.is_owned = false;
9940         LDKChannelMonitorUpdate updates_conv;
9941         updates_conv.inner = (void*)(updates & (~1));
9942         updates_conv.is_owned = false;
9943         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9944         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9945         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
9946         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9947         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
9948         return (long)ret_conv;
9949 }
9950
9951 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
9952         LDKChannelMonitor this_arg_conv;
9953         this_arg_conv.inner = (void*)(this_arg & (~1));
9954         this_arg_conv.is_owned = false;
9955         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
9956         return ret_val;
9957 }
9958
9959 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
9960         LDKChannelMonitor this_arg_conv;
9961         this_arg_conv.inner = (void*)(this_arg & (~1));
9962         this_arg_conv.is_owned = false;
9963         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9964         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
9965         return (long)ret_ref;
9966 }
9967
9968 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
9969         LDKChannelMonitor this_arg_conv;
9970         this_arg_conv.inner = (void*)(this_arg & (~1));
9971         this_arg_conv.is_owned = false;
9972         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
9973         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9974         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9975         for (size_t c = 0; c < ret_var.datalen; c++) {
9976                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9977                 *ret_conv_54_ref = ret_var.data[c];
9978                 ret_arr_ptr[c] = (long)ret_conv_54_ref;
9979         }
9980         FREE(ret_var.data);
9981         return ret_arr;
9982 }
9983
9984 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
9985         LDKChannelMonitor this_arg_conv;
9986         this_arg_conv.inner = (void*)(this_arg & (~1));
9987         this_arg_conv.is_owned = false;
9988         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
9989         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
9990 }
9991
9992 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
9993         LDKChannelMonitor this_arg_conv;
9994         this_arg_conv.inner = (void*)(this_arg & (~1));
9995         this_arg_conv.is_owned = false;
9996         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
9997         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9998         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9999         for (size_t o = 0; o < ret_var.datalen; o++) {
10000                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10001                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
10002                 long ret_conv_14_ref = (long)ret_conv_14_copy;
10003                 ret_arr_ptr[o] = ret_conv_14_ref;
10004         }
10005         FREE(ret_var.data);
10006         return ret_arr;
10007 }
10008
10009 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
10010         LDKChannelMonitor this_arg_conv;
10011         this_arg_conv.inner = (void*)(this_arg & (~1));
10012         this_arg_conv.is_owned = false;
10013         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
10014         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10015         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10016         for (size_t h = 0; h < ret_var.datalen; h++) {
10017                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10018                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
10019                 long ret_conv_7_ref = (long)ret_conv_7_copy;
10020                 ret_arr_ptr[h] = ret_conv_7_ref;
10021         }
10022         FREE(ret_var.data);
10023         return ret_arr;
10024 }
10025
10026 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
10027         LDKChannelMonitor this_arg_conv;
10028         this_arg_conv.inner = (void*)(this_arg & (~1));
10029         this_arg_conv.is_owned = false;
10030         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
10031         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
10032         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
10033         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
10034         for (size_t m = 0; m < ret_var.datalen; m++) {
10035                 LDKTransaction ret_conv_12_var = ret_var.data[m];
10036                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10037                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
10038                 Transaction_free(ret_conv_12_var);
10039                 ret_arr_ptr[m] = ret_conv_12_arr;
10040         }
10041         FREE(ret_var.data);
10042         return ret_arr;
10043 }
10044
10045 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
10046         LDKChannelMonitor this_arg_conv;
10047         this_arg_conv.inner = (void*)(this_arg & (~1));
10048         this_arg_conv.is_owned = false;
10049         unsigned char header_arr[80];
10050         CHECK(*((uint32_t*)header) == 80);
10051         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10052         unsigned char (*header_ref)[80] = &header_arr;
10053         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10054         txdata_constr.datalen = *((uint32_t*)txdata);
10055         if (txdata_constr.datalen > 0)
10056                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10057         else
10058                 txdata_constr.data = NULL;
10059         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
10060         for (size_t e = 0; e < txdata_constr.datalen; e++) {
10061                 uint32_t txdata_conv_30 = txdata_vals[e];
10062                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
10063                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
10064                 txdata_constr.data[e] = txdata_conv_30_conv;
10065         }
10066         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10067         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10068         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10069         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);
10070         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10071         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10072         for (size_t x = 0; x < ret_var.datalen; x++) {
10073                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10074                 *ret_conv_49_ref = ret_var.data[x];
10075                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
10076         }
10077         FREE(ret_var.data);
10078         return ret_arr;
10079 }
10080
10081 void  __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
10082         LDKChannelMonitor this_arg_conv;
10083         this_arg_conv.inner = (void*)(this_arg & (~1));
10084         this_arg_conv.is_owned = false;
10085         unsigned char header_arr[80];
10086         CHECK(*((uint32_t*)header) == 80);
10087         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10088         unsigned char (*header_ref)[80] = &header_arr;
10089         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10090         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10091         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10092         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10093 }
10094
10095 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
10096         if ((this_ptr & 1) != 0) return;
10097         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
10098         FREE((void*)this_ptr);
10099         Persist_free(this_ptr_conv);
10100 }
10101
10102 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
10103         LDKu8slice ser_ref;
10104         ser_ref.datalen = *((uint32_t*)ser);
10105         ser_ref.data = (int8_t*)(ser + 4);
10106         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
10107         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10108         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
10109         return (long)ret_conv;
10110 }
10111
10112 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
10113         LDKOutPoint this_obj_conv;
10114         this_obj_conv.inner = (void*)(this_obj & (~1));
10115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10116         OutPoint_free(this_obj_conv);
10117 }
10118
10119 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
10120         LDKOutPoint this_ptr_conv;
10121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10122         this_ptr_conv.is_owned = false;
10123         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10124         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
10125         return ret_arr;
10126 }
10127
10128 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
10129         LDKOutPoint this_ptr_conv;
10130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10131         this_ptr_conv.is_owned = false;
10132         LDKThirtyTwoBytes val_ref;
10133         CHECK(*((uint32_t*)val) == 32);
10134         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10135         OutPoint_set_txid(&this_ptr_conv, val_ref);
10136 }
10137
10138 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
10139         LDKOutPoint this_ptr_conv;
10140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10141         this_ptr_conv.is_owned = false;
10142         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
10143         return ret_val;
10144 }
10145
10146 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
10147         LDKOutPoint this_ptr_conv;
10148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10149         this_ptr_conv.is_owned = false;
10150         OutPoint_set_index(&this_ptr_conv, val);
10151 }
10152
10153 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
10154         LDKThirtyTwoBytes txid_arg_ref;
10155         CHECK(*((uint32_t*)txid_arg) == 32);
10156         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
10157         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
10158         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10159         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10160         long ret_ref = (long)ret_var.inner;
10161         if (ret_var.is_owned) {
10162                 ret_ref |= 1;
10163         }
10164         return ret_ref;
10165 }
10166
10167 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
10168         LDKOutPoint orig_conv;
10169         orig_conv.inner = (void*)(orig & (~1));
10170         orig_conv.is_owned = false;
10171         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
10172         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10173         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10174         long ret_ref = (long)ret_var.inner;
10175         if (ret_var.is_owned) {
10176                 ret_ref |= 1;
10177         }
10178         return ret_ref;
10179 }
10180
10181 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
10182         LDKOutPoint this_arg_conv;
10183         this_arg_conv.inner = (void*)(this_arg & (~1));
10184         this_arg_conv.is_owned = false;
10185         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10186         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
10187         return ret_arr;
10188 }
10189
10190 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
10191         LDKOutPoint obj_conv;
10192         obj_conv.inner = (void*)(obj & (~1));
10193         obj_conv.is_owned = false;
10194         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
10195         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10196         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10197         CVec_u8Z_free(ret_var);
10198         return ret_arr;
10199 }
10200
10201 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
10202         LDKu8slice ser_ref;
10203         ser_ref.datalen = *((uint32_t*)ser);
10204         ser_ref.data = (int8_t*)(ser + 4);
10205         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10206         *ret_conv = OutPoint_read(ser_ref);
10207         return (long)ret_conv;
10208 }
10209
10210 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
10211         LDKDelayedPaymentOutputDescriptor this_obj_conv;
10212         this_obj_conv.inner = (void*)(this_obj & (~1));
10213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10214         DelayedPaymentOutputDescriptor_free(this_obj_conv);
10215 }
10216
10217 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10218         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10220         this_ptr_conv.is_owned = false;
10221         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10222         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10223         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10224         long ret_ref = (long)ret_var.inner;
10225         if (ret_var.is_owned) {
10226                 ret_ref |= 1;
10227         }
10228         return ret_ref;
10229 }
10230
10231 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10232         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10234         this_ptr_conv.is_owned = false;
10235         LDKOutPoint val_conv;
10236         val_conv.inner = (void*)(val & (~1));
10237         val_conv.is_owned = (val & 1) || (val == 0);
10238         val_conv = OutPoint_clone(&val_conv);
10239         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10240 }
10241
10242 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
10243         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10245         this_ptr_conv.is_owned = false;
10246         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10247         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10248         return ret_arr;
10249 }
10250
10251 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10252         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10254         this_ptr_conv.is_owned = false;
10255         LDKPublicKey val_ref;
10256         CHECK(*((uint32_t*)val) == 33);
10257         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10258         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
10259 }
10260
10261 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
10262         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10264         this_ptr_conv.is_owned = false;
10265         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
10266         return ret_val;
10267 }
10268
10269 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
10270         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10272         this_ptr_conv.is_owned = false;
10273         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
10274 }
10275
10276 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10277         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10279         this_ptr_conv.is_owned = false;
10280         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10281         FREE((void*)val);
10282         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10283 }
10284
10285 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
10286         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10288         this_ptr_conv.is_owned = false;
10289         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10290         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
10291         return ret_arr;
10292 }
10293
10294 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
10295         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10297         this_ptr_conv.is_owned = false;
10298         LDKPublicKey val_ref;
10299         CHECK(*((uint32_t*)val) == 33);
10300         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10301         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
10302 }
10303
10304 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10305         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10307         this_ptr_conv.is_owned = false;
10308         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10309         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10310         return ret_arr;
10311 }
10312
10313 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10314         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10316         this_ptr_conv.is_owned = false;
10317         LDKThirtyTwoBytes val_ref;
10318         CHECK(*((uint32_t*)val) == 32);
10319         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10320         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10321 }
10322
10323 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10324         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10326         this_ptr_conv.is_owned = false;
10327         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10328         return ret_val;
10329 }
10330
10331 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10332         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10334         this_ptr_conv.is_owned = false;
10335         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10336 }
10337
10338 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_new(uint32_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, uint32_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
10339         LDKOutPoint outpoint_arg_conv;
10340         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10341         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10342         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10343         LDKPublicKey per_commitment_point_arg_ref;
10344         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
10345         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
10346         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10347         FREE((void*)output_arg);
10348         LDKPublicKey revocation_pubkey_arg_ref;
10349         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
10350         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
10351         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10352         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10353         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10354         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);
10355         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10356         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10357         long ret_ref = (long)ret_var.inner;
10358         if (ret_var.is_owned) {
10359                 ret_ref |= 1;
10360         }
10361         return ret_ref;
10362 }
10363
10364 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
10365         LDKDelayedPaymentOutputDescriptor orig_conv;
10366         orig_conv.inner = (void*)(orig & (~1));
10367         orig_conv.is_owned = false;
10368         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
10369         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10370         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10371         long ret_ref = (long)ret_var.inner;
10372         if (ret_var.is_owned) {
10373                 ret_ref |= 1;
10374         }
10375         return ret_ref;
10376 }
10377
10378 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
10379         LDKStaticPaymentOutputDescriptor this_obj_conv;
10380         this_obj_conv.inner = (void*)(this_obj & (~1));
10381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10382         StaticPaymentOutputDescriptor_free(this_obj_conv);
10383 }
10384
10385 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10386         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10388         this_ptr_conv.is_owned = false;
10389         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10390         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10391         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10392         long ret_ref = (long)ret_var.inner;
10393         if (ret_var.is_owned) {
10394                 ret_ref |= 1;
10395         }
10396         return ret_ref;
10397 }
10398
10399 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10400         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10402         this_ptr_conv.is_owned = false;
10403         LDKOutPoint val_conv;
10404         val_conv.inner = (void*)(val & (~1));
10405         val_conv.is_owned = (val & 1) || (val == 0);
10406         val_conv = OutPoint_clone(&val_conv);
10407         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10408 }
10409
10410 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10411         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10413         this_ptr_conv.is_owned = false;
10414         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10415         FREE((void*)val);
10416         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10417 }
10418
10419 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10420         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10422         this_ptr_conv.is_owned = false;
10423         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10424         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10425         return ret_arr;
10426 }
10427
10428 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10429         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10431         this_ptr_conv.is_owned = false;
10432         LDKThirtyTwoBytes val_ref;
10433         CHECK(*((uint32_t*)val) == 32);
10434         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10435         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10436 }
10437
10438 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10439         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10441         this_ptr_conv.is_owned = false;
10442         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10443         return ret_val;
10444 }
10445
10446 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10447         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10449         this_ptr_conv.is_owned = false;
10450         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10451 }
10452
10453 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_new(uint32_t outpoint_arg, uint32_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
10454         LDKOutPoint outpoint_arg_conv;
10455         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10456         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10457         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10458         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10459         FREE((void*)output_arg);
10460         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10461         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10462         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10463         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
10464         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10465         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10466         long ret_ref = (long)ret_var.inner;
10467         if (ret_var.is_owned) {
10468                 ret_ref |= 1;
10469         }
10470         return ret_ref;
10471 }
10472
10473 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
10474         LDKStaticPaymentOutputDescriptor orig_conv;
10475         orig_conv.inner = (void*)(orig & (~1));
10476         orig_conv.is_owned = false;
10477         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
10478         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10479         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10480         long ret_ref = (long)ret_var.inner;
10481         if (ret_var.is_owned) {
10482                 ret_ref |= 1;
10483         }
10484         return ret_ref;
10485 }
10486
10487 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
10488         if ((this_ptr & 1) != 0) return;
10489         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
10490         FREE((void*)this_ptr);
10491         SpendableOutputDescriptor_free(this_ptr_conv);
10492 }
10493
10494 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
10495         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
10496         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
10497         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
10498         long ret_ref = (long)ret_copy;
10499         return ret_ref;
10500 }
10501
10502 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
10503         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
10504         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
10505         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10506         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10507         CVec_u8Z_free(ret_var);
10508         return ret_arr;
10509 }
10510
10511 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
10512         LDKu8slice ser_ref;
10513         ser_ref.datalen = *((uint32_t*)ser);
10514         ser_ref.data = (int8_t*)(ser + 4);
10515         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10516         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
10517         return (long)ret_conv;
10518 }
10519
10520 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
10521         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
10522         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10523         *ret = Sign_clone(orig_conv);
10524         return (long)ret;
10525 }
10526
10527 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
10528         if ((this_ptr & 1) != 0) return;
10529         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
10530         FREE((void*)this_ptr);
10531         Sign_free(this_ptr_conv);
10532 }
10533
10534 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
10535         if ((this_ptr & 1) != 0) return;
10536         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
10537         FREE((void*)this_ptr);
10538         KeysInterface_free(this_ptr_conv);
10539 }
10540
10541 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
10542         LDKInMemorySigner this_obj_conv;
10543         this_obj_conv.inner = (void*)(this_obj & (~1));
10544         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10545         InMemorySigner_free(this_obj_conv);
10546 }
10547
10548 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
10549         LDKInMemorySigner this_ptr_conv;
10550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10551         this_ptr_conv.is_owned = false;
10552         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10553         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
10554         return ret_arr;
10555 }
10556
10557 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
10558         LDKInMemorySigner this_ptr_conv;
10559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10560         this_ptr_conv.is_owned = false;
10561         LDKSecretKey val_ref;
10562         CHECK(*((uint32_t*)val) == 32);
10563         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10564         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
10565 }
10566
10567 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
10568         LDKInMemorySigner this_ptr_conv;
10569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10570         this_ptr_conv.is_owned = false;
10571         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10572         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
10573         return ret_arr;
10574 }
10575
10576 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
10577         LDKInMemorySigner this_ptr_conv;
10578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10579         this_ptr_conv.is_owned = false;
10580         LDKSecretKey val_ref;
10581         CHECK(*((uint32_t*)val) == 32);
10582         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10583         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
10584 }
10585
10586 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
10587         LDKInMemorySigner this_ptr_conv;
10588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10589         this_ptr_conv.is_owned = false;
10590         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10591         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
10592         return ret_arr;
10593 }
10594
10595 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
10596         LDKInMemorySigner this_ptr_conv;
10597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10598         this_ptr_conv.is_owned = false;
10599         LDKSecretKey val_ref;
10600         CHECK(*((uint32_t*)val) == 32);
10601         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10602         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
10603 }
10604
10605 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
10606         LDKInMemorySigner this_ptr_conv;
10607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10608         this_ptr_conv.is_owned = false;
10609         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10610         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
10611         return ret_arr;
10612 }
10613
10614 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
10615         LDKInMemorySigner this_ptr_conv;
10616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10617         this_ptr_conv.is_owned = false;
10618         LDKSecretKey val_ref;
10619         CHECK(*((uint32_t*)val) == 32);
10620         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10621         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
10622 }
10623
10624 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
10625         LDKInMemorySigner this_ptr_conv;
10626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10627         this_ptr_conv.is_owned = false;
10628         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10629         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
10630         return ret_arr;
10631 }
10632
10633 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
10634         LDKInMemorySigner this_ptr_conv;
10635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10636         this_ptr_conv.is_owned = false;
10637         LDKSecretKey val_ref;
10638         CHECK(*((uint32_t*)val) == 32);
10639         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10640         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
10641 }
10642
10643 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
10644         LDKInMemorySigner this_ptr_conv;
10645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10646         this_ptr_conv.is_owned = false;
10647         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10648         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
10649         return ret_arr;
10650 }
10651
10652 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
10653         LDKInMemorySigner this_ptr_conv;
10654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10655         this_ptr_conv.is_owned = false;
10656         LDKThirtyTwoBytes val_ref;
10657         CHECK(*((uint32_t*)val) == 32);
10658         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10659         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
10660 }
10661
10662 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
10663         LDKInMemorySigner orig_conv;
10664         orig_conv.inner = (void*)(orig & (~1));
10665         orig_conv.is_owned = false;
10666         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
10667         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10668         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10669         long ret_ref = (long)ret_var.inner;
10670         if (ret_var.is_owned) {
10671                 ret_ref |= 1;
10672         }
10673         return ret_ref;
10674 }
10675
10676 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_new(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) {
10677         LDKSecretKey funding_key_ref;
10678         CHECK(*((uint32_t*)funding_key) == 32);
10679         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
10680         LDKSecretKey revocation_base_key_ref;
10681         CHECK(*((uint32_t*)revocation_base_key) == 32);
10682         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
10683         LDKSecretKey payment_key_ref;
10684         CHECK(*((uint32_t*)payment_key) == 32);
10685         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
10686         LDKSecretKey delayed_payment_base_key_ref;
10687         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
10688         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
10689         LDKSecretKey htlc_base_key_ref;
10690         CHECK(*((uint32_t*)htlc_base_key) == 32);
10691         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
10692         LDKThirtyTwoBytes commitment_seed_ref;
10693         CHECK(*((uint32_t*)commitment_seed) == 32);
10694         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
10695         LDKThirtyTwoBytes channel_keys_id_ref;
10696         CHECK(*((uint32_t*)channel_keys_id) == 32);
10697         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
10698         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);
10699         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10700         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10701         long ret_ref = (long)ret_var.inner;
10702         if (ret_var.is_owned) {
10703                 ret_ref |= 1;
10704         }
10705         return ret_ref;
10706 }
10707
10708 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
10709         LDKInMemorySigner this_arg_conv;
10710         this_arg_conv.inner = (void*)(this_arg & (~1));
10711         this_arg_conv.is_owned = false;
10712         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
10713         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10714         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10715         long ret_ref = (long)ret_var.inner;
10716         if (ret_var.is_owned) {
10717                 ret_ref |= 1;
10718         }
10719         return ret_ref;
10720 }
10721
10722 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
10723         LDKInMemorySigner this_arg_conv;
10724         this_arg_conv.inner = (void*)(this_arg & (~1));
10725         this_arg_conv.is_owned = false;
10726         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
10727         return ret_val;
10728 }
10729
10730 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
10731         LDKInMemorySigner this_arg_conv;
10732         this_arg_conv.inner = (void*)(this_arg & (~1));
10733         this_arg_conv.is_owned = false;
10734         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
10735         return ret_val;
10736 }
10737
10738 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
10739         LDKInMemorySigner this_arg_conv;
10740         this_arg_conv.inner = (void*)(this_arg & (~1));
10741         this_arg_conv.is_owned = false;
10742         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
10743         return ret_val;
10744 }
10745
10746 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
10747         LDKInMemorySigner this_arg_conv;
10748         this_arg_conv.inner = (void*)(this_arg & (~1));
10749         this_arg_conv.is_owned = false;
10750         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
10751         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10752         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10753         long ret_ref = (long)ret_var.inner;
10754         if (ret_var.is_owned) {
10755                 ret_ref |= 1;
10756         }
10757         return ret_ref;
10758 }
10759
10760 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
10761         LDKInMemorySigner this_arg_conv;
10762         this_arg_conv.inner = (void*)(this_arg & (~1));
10763         this_arg_conv.is_owned = false;
10764         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
10765         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10766         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10767         long ret_ref = (long)ret_var.inner;
10768         if (ret_var.is_owned) {
10769                 ret_ref |= 1;
10770         }
10771         return ret_ref;
10772 }
10773
10774 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
10775         LDKInMemorySigner this_arg_conv;
10776         this_arg_conv.inner = (void*)(this_arg & (~1));
10777         this_arg_conv.is_owned = false;
10778         LDKTransaction spend_tx_ref;
10779         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10780         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10781         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10782         spend_tx_ref.data_is_owned = true;
10783         LDKStaticPaymentOutputDescriptor descriptor_conv;
10784         descriptor_conv.inner = (void*)(descriptor & (~1));
10785         descriptor_conv.is_owned = false;
10786         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10787         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10788         return (long)ret_conv;
10789 }
10790
10791 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
10792         LDKInMemorySigner this_arg_conv;
10793         this_arg_conv.inner = (void*)(this_arg & (~1));
10794         this_arg_conv.is_owned = false;
10795         LDKTransaction spend_tx_ref;
10796         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10797         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10798         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10799         spend_tx_ref.data_is_owned = true;
10800         LDKDelayedPaymentOutputDescriptor descriptor_conv;
10801         descriptor_conv.inner = (void*)(descriptor & (~1));
10802         descriptor_conv.is_owned = false;
10803         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10804         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10805         return (long)ret_conv;
10806 }
10807
10808 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
10809         LDKInMemorySigner this_arg_conv;
10810         this_arg_conv.inner = (void*)(this_arg & (~1));
10811         this_arg_conv.is_owned = false;
10812         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10813         *ret = InMemorySigner_as_Sign(&this_arg_conv);
10814         return (long)ret;
10815 }
10816
10817 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
10818         LDKInMemorySigner obj_conv;
10819         obj_conv.inner = (void*)(obj & (~1));
10820         obj_conv.is_owned = false;
10821         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
10822         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10823         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10824         CVec_u8Z_free(ret_var);
10825         return ret_arr;
10826 }
10827
10828 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
10829         LDKu8slice ser_ref;
10830         ser_ref.datalen = *((uint32_t*)ser);
10831         ser_ref.data = (int8_t*)(ser + 4);
10832         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10833         *ret_conv = InMemorySigner_read(ser_ref);
10834         return (long)ret_conv;
10835 }
10836
10837 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
10838         LDKKeysManager this_obj_conv;
10839         this_obj_conv.inner = (void*)(this_obj & (~1));
10840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10841         KeysManager_free(this_obj_conv);
10842 }
10843
10844 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
10845         unsigned char seed_arr[32];
10846         CHECK(*((uint32_t*)seed) == 32);
10847         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
10848         unsigned char (*seed_ref)[32] = &seed_arr;
10849         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
10850         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10851         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10852         long ret_ref = (long)ret_var.inner;
10853         if (ret_var.is_owned) {
10854                 ret_ref |= 1;
10855         }
10856         return ret_ref;
10857 }
10858
10859 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
10860         LDKKeysManager this_arg_conv;
10861         this_arg_conv.inner = (void*)(this_arg & (~1));
10862         this_arg_conv.is_owned = false;
10863         unsigned char params_arr[32];
10864         CHECK(*((uint32_t*)params) == 32);
10865         memcpy(params_arr, (uint8_t*)(params + 4), 32);
10866         unsigned char (*params_ref)[32] = &params_arr;
10867         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
10868         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10869         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10870         long ret_ref = (long)ret_var.inner;
10871         if (ret_var.is_owned) {
10872                 ret_ref |= 1;
10873         }
10874         return ret_ref;
10875 }
10876
10877 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_outputs(uint32_t this_arg, uint32_tArray descriptors, uint32_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
10878         LDKKeysManager this_arg_conv;
10879         this_arg_conv.inner = (void*)(this_arg & (~1));
10880         this_arg_conv.is_owned = false;
10881         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
10882         descriptors_constr.datalen = *((uint32_t*)descriptors);
10883         if (descriptors_constr.datalen > 0)
10884                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10885         else
10886                 descriptors_constr.data = NULL;
10887         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
10888         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
10889                 uint32_t descriptors_conv_27 = descriptors_vals[b];
10890                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
10891                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
10892                 descriptors_constr.data[b] = descriptors_conv_27_conv;
10893         }
10894         LDKCVec_TxOutZ outputs_constr;
10895         outputs_constr.datalen = *((uint32_t*)outputs);
10896         if (outputs_constr.datalen > 0)
10897                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10898         else
10899                 outputs_constr.data = NULL;
10900         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
10901         for (size_t h = 0; h < outputs_constr.datalen; h++) {
10902                 uint32_t outputs_conv_7 = outputs_vals[h];
10903                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
10904                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
10905                 outputs_constr.data[h] = outputs_conv_7_conv;
10906         }
10907         LDKCVec_u8Z change_destination_script_ref;
10908         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
10909         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
10910         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
10911         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10912         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
10913         return (long)ret_conv;
10914 }
10915
10916 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
10917         LDKKeysManager this_arg_conv;
10918         this_arg_conv.inner = (void*)(this_arg & (~1));
10919         this_arg_conv.is_owned = false;
10920         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
10921         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
10922         return (long)ret;
10923 }
10924
10925 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
10926         LDKChannelManager this_obj_conv;
10927         this_obj_conv.inner = (void*)(this_obj & (~1));
10928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10929         ChannelManager_free(this_obj_conv);
10930 }
10931
10932 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
10933         LDKChainParameters this_obj_conv;
10934         this_obj_conv.inner = (void*)(this_obj & (~1));
10935         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10936         ChainParameters_free(this_obj_conv);
10937 }
10938
10939 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
10940         LDKChainParameters this_ptr_conv;
10941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10942         this_ptr_conv.is_owned = false;
10943         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
10944         return ret_conv;
10945 }
10946
10947 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
10948         LDKChainParameters this_ptr_conv;
10949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10950         this_ptr_conv.is_owned = false;
10951         LDKNetwork val_conv = LDKNetwork_from_js(val);
10952         ChainParameters_set_network(&this_ptr_conv, val_conv);
10953 }
10954
10955 int8_tArray  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_hash(uint32_t this_ptr) {
10956         LDKChainParameters this_ptr_conv;
10957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10958         this_ptr_conv.is_owned = false;
10959         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10960         memcpy((uint8_t*)(ret_arr + 4), *ChainParameters_get_latest_hash(&this_ptr_conv), 32);
10961         return ret_arr;
10962 }
10963
10964 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_hash(uint32_t this_ptr, int8_tArray val) {
10965         LDKChainParameters this_ptr_conv;
10966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10967         this_ptr_conv.is_owned = false;
10968         LDKThirtyTwoBytes val_ref;
10969         CHECK(*((uint32_t*)val) == 32);
10970         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10971         ChainParameters_set_latest_hash(&this_ptr_conv, val_ref);
10972 }
10973
10974 int64_t  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_height(uint32_t this_ptr) {
10975         LDKChainParameters this_ptr_conv;
10976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10977         this_ptr_conv.is_owned = false;
10978         int64_t ret_val = ChainParameters_get_latest_height(&this_ptr_conv);
10979         return ret_val;
10980 }
10981
10982 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_height(uint32_t this_ptr, int64_t val) {
10983         LDKChainParameters this_ptr_conv;
10984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10985         this_ptr_conv.is_owned = false;
10986         ChainParameters_set_latest_height(&this_ptr_conv, val);
10987 }
10988
10989 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, int8_tArray latest_hash_arg, int64_t latest_height_arg) {
10990         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
10991         LDKThirtyTwoBytes latest_hash_arg_ref;
10992         CHECK(*((uint32_t*)latest_hash_arg) == 32);
10993         memcpy(latest_hash_arg_ref.data, (uint8_t*)(latest_hash_arg + 4), 32);
10994         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, latest_hash_arg_ref, latest_height_arg);
10995         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10996         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10997         long ret_ref = (long)ret_var.inner;
10998         if (ret_var.is_owned) {
10999                 ret_ref |= 1;
11000         }
11001         return ret_ref;
11002 }
11003
11004 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
11005         LDKChannelDetails this_obj_conv;
11006         this_obj_conv.inner = (void*)(this_obj & (~1));
11007         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11008         ChannelDetails_free(this_obj_conv);
11009 }
11010
11011 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
11012         LDKChannelDetails this_ptr_conv;
11013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11014         this_ptr_conv.is_owned = false;
11015         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11016         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
11017         return ret_arr;
11018 }
11019
11020 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
11021         LDKChannelDetails this_ptr_conv;
11022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11023         this_ptr_conv.is_owned = false;
11024         LDKThirtyTwoBytes val_ref;
11025         CHECK(*((uint32_t*)val) == 32);
11026         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11027         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
11028 }
11029
11030 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
11031         LDKChannelDetails this_ptr_conv;
11032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11033         this_ptr_conv.is_owned = false;
11034         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11035         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
11036         long ret_ref = (long)ret_copy;
11037         return ret_ref;
11038 }
11039
11040 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
11041         LDKChannelDetails this_ptr_conv;
11042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11043         this_ptr_conv.is_owned = false;
11044         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
11045         FREE((void*)val);
11046         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
11047 }
11048
11049 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
11050         LDKChannelDetails this_ptr_conv;
11051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11052         this_ptr_conv.is_owned = false;
11053         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11054         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
11055         return ret_arr;
11056 }
11057
11058 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
11059         LDKChannelDetails this_ptr_conv;
11060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11061         this_ptr_conv.is_owned = false;
11062         LDKPublicKey val_ref;
11063         CHECK(*((uint32_t*)val) == 33);
11064         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11065         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
11066 }
11067
11068 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
11069         LDKChannelDetails this_ptr_conv;
11070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11071         this_ptr_conv.is_owned = false;
11072         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
11073         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11074         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11075         long ret_ref = (long)ret_var.inner;
11076         if (ret_var.is_owned) {
11077                 ret_ref |= 1;
11078         }
11079         return ret_ref;
11080 }
11081
11082 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
11083         LDKChannelDetails this_ptr_conv;
11084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11085         this_ptr_conv.is_owned = false;
11086         LDKInitFeatures val_conv;
11087         val_conv.inner = (void*)(val & (~1));
11088         val_conv.is_owned = (val & 1) || (val == 0);
11089         val_conv = InitFeatures_clone(&val_conv);
11090         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
11091 }
11092
11093 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
11094         LDKChannelDetails this_ptr_conv;
11095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11096         this_ptr_conv.is_owned = false;
11097         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
11098         return ret_val;
11099 }
11100
11101 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
11102         LDKChannelDetails this_ptr_conv;
11103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11104         this_ptr_conv.is_owned = false;
11105         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
11106 }
11107
11108 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
11109         LDKChannelDetails this_ptr_conv;
11110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11111         this_ptr_conv.is_owned = false;
11112         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
11113         return ret_val;
11114 }
11115
11116 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
11117         LDKChannelDetails this_ptr_conv;
11118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11119         this_ptr_conv.is_owned = false;
11120         ChannelDetails_set_user_id(&this_ptr_conv, val);
11121 }
11122
11123 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
11124         LDKChannelDetails this_ptr_conv;
11125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11126         this_ptr_conv.is_owned = false;
11127         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
11128         return ret_val;
11129 }
11130
11131 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
11132         LDKChannelDetails this_ptr_conv;
11133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11134         this_ptr_conv.is_owned = false;
11135         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
11136 }
11137
11138 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
11139         LDKChannelDetails this_ptr_conv;
11140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11141         this_ptr_conv.is_owned = false;
11142         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
11143         return ret_val;
11144 }
11145
11146 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
11147         LDKChannelDetails this_ptr_conv;
11148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11149         this_ptr_conv.is_owned = false;
11150         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
11151 }
11152
11153 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
11154         LDKChannelDetails this_ptr_conv;
11155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11156         this_ptr_conv.is_owned = false;
11157         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
11158         return ret_val;
11159 }
11160
11161 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
11162         LDKChannelDetails this_ptr_conv;
11163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11164         this_ptr_conv.is_owned = false;
11165         ChannelDetails_set_is_live(&this_ptr_conv, val);
11166 }
11167
11168 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
11169         LDKChannelDetails orig_conv;
11170         orig_conv.inner = (void*)(orig & (~1));
11171         orig_conv.is_owned = false;
11172         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
11173         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11174         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11175         long ret_ref = (long)ret_var.inner;
11176         if (ret_var.is_owned) {
11177                 ret_ref |= 1;
11178         }
11179         return ret_ref;
11180 }
11181
11182 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
11183         if ((this_ptr & 1) != 0) return;
11184         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
11185         FREE((void*)this_ptr);
11186         PaymentSendFailure_free(this_ptr_conv);
11187 }
11188
11189 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
11190         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
11191         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
11192         *ret_copy = PaymentSendFailure_clone(orig_conv);
11193         long ret_ref = (long)ret_copy;
11194         return ret_ref;
11195 }
11196
11197 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) {
11198         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
11199         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11200         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11201         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11202         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11203         LDKUserConfig config_conv;
11204         config_conv.inner = (void*)(config & (~1));
11205         config_conv.is_owned = (config & 1) || (config == 0);
11206         config_conv = UserConfig_clone(&config_conv);
11207         LDKChainParameters params_conv;
11208         params_conv.inner = (void*)(params & (~1));
11209         params_conv.is_owned = (params & 1) || (params == 0);
11210         // Warning: we need a move here but no clone is available for LDKChainParameters
11211         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
11212         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11213         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11214         long ret_ref = (long)ret_var.inner;
11215         if (ret_var.is_owned) {
11216                 ret_ref |= 1;
11217         }
11218         return ret_ref;
11219 }
11220
11221 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, uint32_t override_config) {
11222         LDKChannelManager this_arg_conv;
11223         this_arg_conv.inner = (void*)(this_arg & (~1));
11224         this_arg_conv.is_owned = false;
11225         LDKPublicKey their_network_key_ref;
11226         CHECK(*((uint32_t*)their_network_key) == 33);
11227         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
11228         LDKUserConfig override_config_conv;
11229         override_config_conv.inner = (void*)(override_config & (~1));
11230         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
11231         override_config_conv = UserConfig_clone(&override_config_conv);
11232         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11233         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
11234         return (long)ret_conv;
11235 }
11236
11237 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
11238         LDKChannelManager this_arg_conv;
11239         this_arg_conv.inner = (void*)(this_arg & (~1));
11240         this_arg_conv.is_owned = false;
11241         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
11242         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11243         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11244         for (size_t q = 0; q < ret_var.datalen; q++) {
11245                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11246                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11247                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11248                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11249                 if (ret_conv_16_var.is_owned) {
11250                         ret_conv_16_ref |= 1;
11251                 }
11252                 ret_arr_ptr[q] = ret_conv_16_ref;
11253         }
11254         FREE(ret_var.data);
11255         return ret_arr;
11256 }
11257
11258 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
11259         LDKChannelManager this_arg_conv;
11260         this_arg_conv.inner = (void*)(this_arg & (~1));
11261         this_arg_conv.is_owned = false;
11262         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
11263         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11264         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11265         for (size_t q = 0; q < ret_var.datalen; q++) {
11266                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11267                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11268                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11269                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11270                 if (ret_conv_16_var.is_owned) {
11271                         ret_conv_16_ref |= 1;
11272                 }
11273                 ret_arr_ptr[q] = ret_conv_16_ref;
11274         }
11275         FREE(ret_var.data);
11276         return ret_arr;
11277 }
11278
11279 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
11280         LDKChannelManager this_arg_conv;
11281         this_arg_conv.inner = (void*)(this_arg & (~1));
11282         this_arg_conv.is_owned = false;
11283         unsigned char channel_id_arr[32];
11284         CHECK(*((uint32_t*)channel_id) == 32);
11285         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
11286         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11287         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11288         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
11289         return (long)ret_conv;
11290 }
11291
11292 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
11293         LDKChannelManager this_arg_conv;
11294         this_arg_conv.inner = (void*)(this_arg & (~1));
11295         this_arg_conv.is_owned = false;
11296         unsigned char channel_id_arr[32];
11297         CHECK(*((uint32_t*)channel_id) == 32);
11298         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
11299         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11300         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11301         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
11302         return (long)ret_conv;
11303 }
11304
11305 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
11306         LDKChannelManager this_arg_conv;
11307         this_arg_conv.inner = (void*)(this_arg & (~1));
11308         this_arg_conv.is_owned = false;
11309         ChannelManager_force_close_all_channels(&this_arg_conv);
11310 }
11311
11312 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
11313         LDKChannelManager this_arg_conv;
11314         this_arg_conv.inner = (void*)(this_arg & (~1));
11315         this_arg_conv.is_owned = false;
11316         LDKRoute route_conv;
11317         route_conv.inner = (void*)(route & (~1));
11318         route_conv.is_owned = false;
11319         LDKThirtyTwoBytes payment_hash_ref;
11320         CHECK(*((uint32_t*)payment_hash) == 32);
11321         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11322         LDKThirtyTwoBytes payment_secret_ref;
11323         CHECK(*((uint32_t*)payment_secret) == 32);
11324         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11325         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11326         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
11327         return (long)ret_conv;
11328 }
11329
11330 void  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
11331         LDKChannelManager this_arg_conv;
11332         this_arg_conv.inner = (void*)(this_arg & (~1));
11333         this_arg_conv.is_owned = false;
11334         unsigned char temporary_channel_id_arr[32];
11335         CHECK(*((uint32_t*)temporary_channel_id) == 32);
11336         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
11337         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
11338         LDKOutPoint funding_txo_conv;
11339         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11340         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
11341         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
11342         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
11343 }
11344
11345 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
11346         LDKChannelManager this_arg_conv;
11347         this_arg_conv.inner = (void*)(this_arg & (~1));
11348         this_arg_conv.is_owned = false;
11349         LDKThreeBytes rgb_ref;
11350         CHECK(*((uint32_t*)rgb) == 3);
11351         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
11352         LDKThirtyTwoBytes alias_ref;
11353         CHECK(*((uint32_t*)alias) == 32);
11354         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
11355         LDKCVec_NetAddressZ addresses_constr;
11356         addresses_constr.datalen = *((uint32_t*)addresses);
11357         if (addresses_constr.datalen > 0)
11358                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11359         else
11360                 addresses_constr.data = NULL;
11361         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
11362         for (size_t m = 0; m < addresses_constr.datalen; m++) {
11363                 uint32_t addresses_conv_12 = addresses_vals[m];
11364                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
11365                 FREE((void*)addresses_conv_12);
11366                 addresses_constr.data[m] = addresses_conv_12_conv;
11367         }
11368         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
11369 }
11370
11371 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
11372         LDKChannelManager this_arg_conv;
11373         this_arg_conv.inner = (void*)(this_arg & (~1));
11374         this_arg_conv.is_owned = false;
11375         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11376 }
11377
11378 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
11379         LDKChannelManager this_arg_conv;
11380         this_arg_conv.inner = (void*)(this_arg & (~1));
11381         this_arg_conv.is_owned = false;
11382         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
11383 }
11384
11385 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11386         LDKChannelManager this_arg_conv;
11387         this_arg_conv.inner = (void*)(this_arg & (~1));
11388         this_arg_conv.is_owned = false;
11389         unsigned char payment_hash_arr[32];
11390         CHECK(*((uint32_t*)payment_hash) == 32);
11391         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
11392         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11393         LDKThirtyTwoBytes payment_secret_ref;
11394         CHECK(*((uint32_t*)payment_secret) == 32);
11395         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11396         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11397         return ret_val;
11398 }
11399
11400 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11401         LDKChannelManager this_arg_conv;
11402         this_arg_conv.inner = (void*)(this_arg & (~1));
11403         this_arg_conv.is_owned = false;
11404         LDKThirtyTwoBytes payment_preimage_ref;
11405         CHECK(*((uint32_t*)payment_preimage) == 32);
11406         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11407         LDKThirtyTwoBytes payment_secret_ref;
11408         CHECK(*((uint32_t*)payment_secret) == 32);
11409         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11410         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
11411         return ret_val;
11412 }
11413
11414 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
11415         LDKChannelManager this_arg_conv;
11416         this_arg_conv.inner = (void*)(this_arg & (~1));
11417         this_arg_conv.is_owned = false;
11418         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11419         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
11420         return ret_arr;
11421 }
11422
11423 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
11424         LDKChannelManager this_arg_conv;
11425         this_arg_conv.inner = (void*)(this_arg & (~1));
11426         this_arg_conv.is_owned = false;
11427         LDKOutPoint funding_txo_conv;
11428         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11429         funding_txo_conv.is_owned = false;
11430         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
11431 }
11432
11433 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
11434         LDKChannelManager this_arg_conv;
11435         this_arg_conv.inner = (void*)(this_arg & (~1));
11436         this_arg_conv.is_owned = false;
11437         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11438         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
11439         return (long)ret;
11440 }
11441
11442 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
11443         LDKChannelManager this_arg_conv;
11444         this_arg_conv.inner = (void*)(this_arg & (~1));
11445         this_arg_conv.is_owned = false;
11446         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11447         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
11448         return (long)ret;
11449 }
11450
11451 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
11452         LDKChannelManager this_arg_conv;
11453         this_arg_conv.inner = (void*)(this_arg & (~1));
11454         this_arg_conv.is_owned = false;
11455         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11456         *ret = ChannelManager_as_Listen(&this_arg_conv);
11457         return (long)ret;
11458 }
11459
11460 void  __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
11461         LDKChannelManager this_arg_conv;
11462         this_arg_conv.inner = (void*)(this_arg & (~1));
11463         this_arg_conv.is_owned = false;
11464         unsigned char header_arr[80];
11465         CHECK(*((uint32_t*)header) == 80);
11466         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11467         unsigned char (*header_ref)[80] = &header_arr;
11468         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11469         txdata_constr.datalen = *((uint32_t*)txdata);
11470         if (txdata_constr.datalen > 0)
11471                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11472         else
11473                 txdata_constr.data = NULL;
11474         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11475         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11476                 uint32_t txdata_conv_30 = txdata_vals[e];
11477                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11478                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11479                 txdata_constr.data[e] = txdata_conv_30_conv;
11480         }
11481         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11482 }
11483
11484 void  __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
11485         LDKChannelManager this_arg_conv;
11486         this_arg_conv.inner = (void*)(this_arg & (~1));
11487         this_arg_conv.is_owned = false;
11488         unsigned char header_arr[80];
11489         CHECK(*((uint32_t*)header) == 80);
11490         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11491         unsigned char (*header_ref)[80] = &header_arr;
11492         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
11493 }
11494
11495 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
11496         LDKChannelManager this_arg_conv;
11497         this_arg_conv.inner = (void*)(this_arg & (~1));
11498         this_arg_conv.is_owned = false;
11499         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
11500         return ret_val;
11501 }
11502
11503 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
11504         LDKChannelManager this_arg_conv;
11505         this_arg_conv.inner = (void*)(this_arg & (~1));
11506         this_arg_conv.is_owned = false;
11507         ChannelManager_await_persistable_update(&this_arg_conv);
11508 }
11509
11510 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
11511         LDKChannelManager this_arg_conv;
11512         this_arg_conv.inner = (void*)(this_arg & (~1));
11513         this_arg_conv.is_owned = false;
11514         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11515         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
11516         return (long)ret;
11517 }
11518
11519 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
11520         LDKChannelManager obj_conv;
11521         obj_conv.inner = (void*)(obj & (~1));
11522         obj_conv.is_owned = false;
11523         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
11524         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11525         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11526         CVec_u8Z_free(ret_var);
11527         return ret_arr;
11528 }
11529
11530 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
11531         LDKChannelManagerReadArgs this_obj_conv;
11532         this_obj_conv.inner = (void*)(this_obj & (~1));
11533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11534         ChannelManagerReadArgs_free(this_obj_conv);
11535 }
11536
11537 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
11538         LDKChannelManagerReadArgs this_ptr_conv;
11539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11540         this_ptr_conv.is_owned = false;
11541         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
11542         return ret_ret;
11543 }
11544
11545 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
11546         LDKChannelManagerReadArgs this_ptr_conv;
11547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11548         this_ptr_conv.is_owned = false;
11549         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
11550         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
11551 }
11552
11553 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
11554         LDKChannelManagerReadArgs this_ptr_conv;
11555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11556         this_ptr_conv.is_owned = false;
11557         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
11558         return ret_ret;
11559 }
11560
11561 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
11562         LDKChannelManagerReadArgs this_ptr_conv;
11563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11564         this_ptr_conv.is_owned = false;
11565         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
11566         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
11567 }
11568
11569 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
11570         LDKChannelManagerReadArgs this_ptr_conv;
11571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11572         this_ptr_conv.is_owned = false;
11573         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
11574         return ret_ret;
11575 }
11576
11577 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
11578         LDKChannelManagerReadArgs this_ptr_conv;
11579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11580         this_ptr_conv.is_owned = false;
11581         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
11582         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
11583 }
11584
11585 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
11586         LDKChannelManagerReadArgs this_ptr_conv;
11587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11588         this_ptr_conv.is_owned = false;
11589         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
11590         return ret_ret;
11591 }
11592
11593 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
11594         LDKChannelManagerReadArgs this_ptr_conv;
11595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11596         this_ptr_conv.is_owned = false;
11597         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
11598         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
11599 }
11600
11601 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
11602         LDKChannelManagerReadArgs this_ptr_conv;
11603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11604         this_ptr_conv.is_owned = false;
11605         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
11606         return ret_ret;
11607 }
11608
11609 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
11610         LDKChannelManagerReadArgs this_ptr_conv;
11611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11612         this_ptr_conv.is_owned = false;
11613         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
11614         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
11615 }
11616
11617 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
11618         LDKChannelManagerReadArgs this_ptr_conv;
11619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11620         this_ptr_conv.is_owned = false;
11621         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
11622         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11623         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11624         long ret_ref = (long)ret_var.inner;
11625         if (ret_var.is_owned) {
11626                 ret_ref |= 1;
11627         }
11628         return ret_ref;
11629 }
11630
11631 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
11632         LDKChannelManagerReadArgs this_ptr_conv;
11633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11634         this_ptr_conv.is_owned = false;
11635         LDKUserConfig val_conv;
11636         val_conv.inner = (void*)(val & (~1));
11637         val_conv.is_owned = (val & 1) || (val == 0);
11638         val_conv = UserConfig_clone(&val_conv);
11639         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
11640 }
11641
11642 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
11643         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11644         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11645         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11646         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11647         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11648         LDKUserConfig default_config_conv;
11649         default_config_conv.inner = (void*)(default_config & (~1));
11650         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
11651         default_config_conv = UserConfig_clone(&default_config_conv);
11652         LDKCVec_ChannelMonitorZ channel_monitors_constr;
11653         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
11654         if (channel_monitors_constr.datalen > 0)
11655                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11656         else
11657                 channel_monitors_constr.data = NULL;
11658         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
11659         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
11660                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
11661                 LDKChannelMonitor channel_monitors_conv_16_conv;
11662                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
11663                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
11664                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
11665         }
11666         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);
11667         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11668         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11669         long ret_ref = (long)ret_var.inner;
11670         if (ret_var.is_owned) {
11671                 ret_ref |= 1;
11672         }
11673         return ret_ref;
11674 }
11675
11676 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
11677         LDKu8slice ser_ref;
11678         ser_ref.datalen = *((uint32_t*)ser);
11679         ser_ref.data = (int8_t*)(ser + 4);
11680         LDKChannelManagerReadArgs arg_conv;
11681         arg_conv.inner = (void*)(arg & (~1));
11682         arg_conv.is_owned = (arg & 1) || (arg == 0);
11683         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
11684         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11685         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
11686         return (long)ret_conv;
11687 }
11688
11689 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
11690         LDKDecodeError this_obj_conv;
11691         this_obj_conv.inner = (void*)(this_obj & (~1));
11692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11693         DecodeError_free(this_obj_conv);
11694 }
11695
11696 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
11697         LDKDecodeError orig_conv;
11698         orig_conv.inner = (void*)(orig & (~1));
11699         orig_conv.is_owned = false;
11700         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
11701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11703         long ret_ref = (long)ret_var.inner;
11704         if (ret_var.is_owned) {
11705                 ret_ref |= 1;
11706         }
11707         return ret_ref;
11708 }
11709
11710 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
11711         LDKInit this_obj_conv;
11712         this_obj_conv.inner = (void*)(this_obj & (~1));
11713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11714         Init_free(this_obj_conv);
11715 }
11716
11717 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
11718         LDKInit this_ptr_conv;
11719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11720         this_ptr_conv.is_owned = false;
11721         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
11722         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11723         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11724         long ret_ref = (long)ret_var.inner;
11725         if (ret_var.is_owned) {
11726                 ret_ref |= 1;
11727         }
11728         return ret_ref;
11729 }
11730
11731 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
11732         LDKInit this_ptr_conv;
11733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11734         this_ptr_conv.is_owned = false;
11735         LDKInitFeatures val_conv;
11736         val_conv.inner = (void*)(val & (~1));
11737         val_conv.is_owned = (val & 1) || (val == 0);
11738         val_conv = InitFeatures_clone(&val_conv);
11739         Init_set_features(&this_ptr_conv, val_conv);
11740 }
11741
11742 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
11743         LDKInitFeatures features_arg_conv;
11744         features_arg_conv.inner = (void*)(features_arg & (~1));
11745         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
11746         features_arg_conv = InitFeatures_clone(&features_arg_conv);
11747         LDKInit ret_var = Init_new(features_arg_conv);
11748         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11749         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11750         long ret_ref = (long)ret_var.inner;
11751         if (ret_var.is_owned) {
11752                 ret_ref |= 1;
11753         }
11754         return ret_ref;
11755 }
11756
11757 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
11758         LDKInit orig_conv;
11759         orig_conv.inner = (void*)(orig & (~1));
11760         orig_conv.is_owned = false;
11761         LDKInit ret_var = Init_clone(&orig_conv);
11762         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11763         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11764         long ret_ref = (long)ret_var.inner;
11765         if (ret_var.is_owned) {
11766                 ret_ref |= 1;
11767         }
11768         return ret_ref;
11769 }
11770
11771 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
11772         LDKErrorMessage this_obj_conv;
11773         this_obj_conv.inner = (void*)(this_obj & (~1));
11774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11775         ErrorMessage_free(this_obj_conv);
11776 }
11777
11778 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
11779         LDKErrorMessage this_ptr_conv;
11780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11781         this_ptr_conv.is_owned = false;
11782         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11783         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
11784         return ret_arr;
11785 }
11786
11787 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
11788         LDKErrorMessage this_ptr_conv;
11789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11790         this_ptr_conv.is_owned = false;
11791         LDKThirtyTwoBytes val_ref;
11792         CHECK(*((uint32_t*)val) == 32);
11793         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11794         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
11795 }
11796
11797 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
11798         LDKErrorMessage this_ptr_conv;
11799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11800         this_ptr_conv.is_owned = false;
11801         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
11802         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11803         return _conv;
11804 }
11805
11806 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
11807         LDKErrorMessage this_ptr_conv;
11808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11809         this_ptr_conv.is_owned = false;
11810         LDKCVec_u8Z val_ref;
11811         val_ref.datalen = *((uint32_t*)val);
11812         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11813         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11814         ErrorMessage_set_data(&this_ptr_conv, val_ref);
11815 }
11816
11817 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
11818         LDKThirtyTwoBytes channel_id_arg_ref;
11819         CHECK(*((uint32_t*)channel_id_arg) == 32);
11820         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
11821         LDKCVec_u8Z data_arg_ref;
11822         data_arg_ref.datalen = *((uint32_t*)data_arg);
11823         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11824         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
11825         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
11826         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11827         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11828         long ret_ref = (long)ret_var.inner;
11829         if (ret_var.is_owned) {
11830                 ret_ref |= 1;
11831         }
11832         return ret_ref;
11833 }
11834
11835 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
11836         LDKErrorMessage orig_conv;
11837         orig_conv.inner = (void*)(orig & (~1));
11838         orig_conv.is_owned = false;
11839         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
11840         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11841         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11842         long ret_ref = (long)ret_var.inner;
11843         if (ret_var.is_owned) {
11844                 ret_ref |= 1;
11845         }
11846         return ret_ref;
11847 }
11848
11849 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
11850         LDKPing this_obj_conv;
11851         this_obj_conv.inner = (void*)(this_obj & (~1));
11852         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11853         Ping_free(this_obj_conv);
11854 }
11855
11856 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
11857         LDKPing this_ptr_conv;
11858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11859         this_ptr_conv.is_owned = false;
11860         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
11861         return ret_val;
11862 }
11863
11864 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
11865         LDKPing this_ptr_conv;
11866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11867         this_ptr_conv.is_owned = false;
11868         Ping_set_ponglen(&this_ptr_conv, val);
11869 }
11870
11871 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
11872         LDKPing this_ptr_conv;
11873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11874         this_ptr_conv.is_owned = false;
11875         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
11876         return ret_val;
11877 }
11878
11879 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
11880         LDKPing this_ptr_conv;
11881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11882         this_ptr_conv.is_owned = false;
11883         Ping_set_byteslen(&this_ptr_conv, val);
11884 }
11885
11886 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
11887         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
11888         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11889         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11890         long ret_ref = (long)ret_var.inner;
11891         if (ret_var.is_owned) {
11892                 ret_ref |= 1;
11893         }
11894         return ret_ref;
11895 }
11896
11897 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
11898         LDKPing orig_conv;
11899         orig_conv.inner = (void*)(orig & (~1));
11900         orig_conv.is_owned = false;
11901         LDKPing ret_var = Ping_clone(&orig_conv);
11902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11904         long ret_ref = (long)ret_var.inner;
11905         if (ret_var.is_owned) {
11906                 ret_ref |= 1;
11907         }
11908         return ret_ref;
11909 }
11910
11911 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
11912         LDKPong this_obj_conv;
11913         this_obj_conv.inner = (void*)(this_obj & (~1));
11914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11915         Pong_free(this_obj_conv);
11916 }
11917
11918 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
11919         LDKPong this_ptr_conv;
11920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11921         this_ptr_conv.is_owned = false;
11922         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
11923         return ret_val;
11924 }
11925
11926 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
11927         LDKPong this_ptr_conv;
11928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11929         this_ptr_conv.is_owned = false;
11930         Pong_set_byteslen(&this_ptr_conv, val);
11931 }
11932
11933 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
11934         LDKPong ret_var = Pong_new(byteslen_arg);
11935         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11936         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11937         long ret_ref = (long)ret_var.inner;
11938         if (ret_var.is_owned) {
11939                 ret_ref |= 1;
11940         }
11941         return ret_ref;
11942 }
11943
11944 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
11945         LDKPong orig_conv;
11946         orig_conv.inner = (void*)(orig & (~1));
11947         orig_conv.is_owned = false;
11948         LDKPong ret_var = Pong_clone(&orig_conv);
11949         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11950         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11951         long ret_ref = (long)ret_var.inner;
11952         if (ret_var.is_owned) {
11953                 ret_ref |= 1;
11954         }
11955         return ret_ref;
11956 }
11957
11958 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
11959         LDKOpenChannel this_obj_conv;
11960         this_obj_conv.inner = (void*)(this_obj & (~1));
11961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11962         OpenChannel_free(this_obj_conv);
11963 }
11964
11965 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
11966         LDKOpenChannel this_ptr_conv;
11967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11968         this_ptr_conv.is_owned = false;
11969         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11970         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
11971         return ret_arr;
11972 }
11973
11974 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11975         LDKOpenChannel this_ptr_conv;
11976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11977         this_ptr_conv.is_owned = false;
11978         LDKThirtyTwoBytes val_ref;
11979         CHECK(*((uint32_t*)val) == 32);
11980         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11981         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
11982 }
11983
11984 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
11985         LDKOpenChannel this_ptr_conv;
11986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11987         this_ptr_conv.is_owned = false;
11988         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11989         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
11990         return ret_arr;
11991 }
11992
11993 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
11994         LDKOpenChannel this_ptr_conv;
11995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11996         this_ptr_conv.is_owned = false;
11997         LDKThirtyTwoBytes val_ref;
11998         CHECK(*((uint32_t*)val) == 32);
11999         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12000         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12001 }
12002
12003 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
12004         LDKOpenChannel this_ptr_conv;
12005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12006         this_ptr_conv.is_owned = false;
12007         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
12008         return ret_val;
12009 }
12010
12011 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
12012         LDKOpenChannel this_ptr_conv;
12013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12014         this_ptr_conv.is_owned = false;
12015         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
12016 }
12017
12018 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
12019         LDKOpenChannel this_ptr_conv;
12020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12021         this_ptr_conv.is_owned = false;
12022         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
12023         return ret_val;
12024 }
12025
12026 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
12027         LDKOpenChannel this_ptr_conv;
12028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12029         this_ptr_conv.is_owned = false;
12030         OpenChannel_set_push_msat(&this_ptr_conv, val);
12031 }
12032
12033 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
12034         LDKOpenChannel this_ptr_conv;
12035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12036         this_ptr_conv.is_owned = false;
12037         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
12038         return ret_val;
12039 }
12040
12041 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
12042         LDKOpenChannel this_ptr_conv;
12043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12044         this_ptr_conv.is_owned = false;
12045         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12046 }
12047
12048 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12049         LDKOpenChannel this_ptr_conv;
12050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12051         this_ptr_conv.is_owned = false;
12052         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12053         return ret_val;
12054 }
12055
12056 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12057         LDKOpenChannel this_ptr_conv;
12058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12059         this_ptr_conv.is_owned = false;
12060         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12061 }
12062
12063 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
12064         LDKOpenChannel this_ptr_conv;
12065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12066         this_ptr_conv.is_owned = false;
12067         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12068         return ret_val;
12069 }
12070
12071 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12072         LDKOpenChannel this_ptr_conv;
12073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12074         this_ptr_conv.is_owned = false;
12075         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12076 }
12077
12078 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
12079         LDKOpenChannel this_ptr_conv;
12080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12081         this_ptr_conv.is_owned = false;
12082         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
12083         return ret_val;
12084 }
12085
12086 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12087         LDKOpenChannel this_ptr_conv;
12088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12089         this_ptr_conv.is_owned = false;
12090         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12091 }
12092
12093 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
12094         LDKOpenChannel this_ptr_conv;
12095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12096         this_ptr_conv.is_owned = false;
12097         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
12098         return ret_val;
12099 }
12100
12101 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
12102         LDKOpenChannel this_ptr_conv;
12103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12104         this_ptr_conv.is_owned = false;
12105         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
12106 }
12107
12108 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
12109         LDKOpenChannel this_ptr_conv;
12110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12111         this_ptr_conv.is_owned = false;
12112         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
12113         return ret_val;
12114 }
12115
12116 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12117         LDKOpenChannel this_ptr_conv;
12118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12119         this_ptr_conv.is_owned = false;
12120         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
12121 }
12122
12123 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12124         LDKOpenChannel this_ptr_conv;
12125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12126         this_ptr_conv.is_owned = false;
12127         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
12128         return ret_val;
12129 }
12130
12131 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12132         LDKOpenChannel this_ptr_conv;
12133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12134         this_ptr_conv.is_owned = false;
12135         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12136 }
12137
12138 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
12139         LDKOpenChannel this_ptr_conv;
12140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12141         this_ptr_conv.is_owned = false;
12142         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12143         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12144         return ret_arr;
12145 }
12146
12147 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12148         LDKOpenChannel this_ptr_conv;
12149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12150         this_ptr_conv.is_owned = false;
12151         LDKPublicKey val_ref;
12152         CHECK(*((uint32_t*)val) == 33);
12153         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12154         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12155 }
12156
12157 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
12158         LDKOpenChannel this_ptr_conv;
12159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12160         this_ptr_conv.is_owned = false;
12161         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12162         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12163         return ret_arr;
12164 }
12165
12166 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12167         LDKOpenChannel this_ptr_conv;
12168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12169         this_ptr_conv.is_owned = false;
12170         LDKPublicKey val_ref;
12171         CHECK(*((uint32_t*)val) == 33);
12172         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12173         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12174 }
12175
12176 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
12177         LDKOpenChannel this_ptr_conv;
12178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12179         this_ptr_conv.is_owned = false;
12180         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12181         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12182         return ret_arr;
12183 }
12184
12185 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12186         LDKOpenChannel this_ptr_conv;
12187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12188         this_ptr_conv.is_owned = false;
12189         LDKPublicKey val_ref;
12190         CHECK(*((uint32_t*)val) == 33);
12191         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12192         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
12193 }
12194
12195 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12196         LDKOpenChannel this_ptr_conv;
12197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12198         this_ptr_conv.is_owned = false;
12199         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12200         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12201         return ret_arr;
12202 }
12203
12204 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12205         LDKOpenChannel this_ptr_conv;
12206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12207         this_ptr_conv.is_owned = false;
12208         LDKPublicKey val_ref;
12209         CHECK(*((uint32_t*)val) == 33);
12210         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12211         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12212 }
12213
12214 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
12215         LDKOpenChannel this_ptr_conv;
12216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12217         this_ptr_conv.is_owned = false;
12218         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12219         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12220         return ret_arr;
12221 }
12222
12223 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12224         LDKOpenChannel this_ptr_conv;
12225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12226         this_ptr_conv.is_owned = false;
12227         LDKPublicKey val_ref;
12228         CHECK(*((uint32_t*)val) == 33);
12229         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12230         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12231 }
12232
12233 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12234         LDKOpenChannel this_ptr_conv;
12235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12236         this_ptr_conv.is_owned = false;
12237         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12238         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12239         return ret_arr;
12240 }
12241
12242 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12243         LDKOpenChannel this_ptr_conv;
12244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12245         this_ptr_conv.is_owned = false;
12246         LDKPublicKey val_ref;
12247         CHECK(*((uint32_t*)val) == 33);
12248         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12249         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12250 }
12251
12252 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
12253         LDKOpenChannel this_ptr_conv;
12254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12255         this_ptr_conv.is_owned = false;
12256         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
12257         return ret_val;
12258 }
12259
12260 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
12261         LDKOpenChannel this_ptr_conv;
12262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12263         this_ptr_conv.is_owned = false;
12264         OpenChannel_set_channel_flags(&this_ptr_conv, val);
12265 }
12266
12267 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
12268         LDKOpenChannel orig_conv;
12269         orig_conv.inner = (void*)(orig & (~1));
12270         orig_conv.is_owned = false;
12271         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
12272         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12273         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12274         long ret_ref = (long)ret_var.inner;
12275         if (ret_var.is_owned) {
12276                 ret_ref |= 1;
12277         }
12278         return ret_ref;
12279 }
12280
12281 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
12282         LDKAcceptChannel this_obj_conv;
12283         this_obj_conv.inner = (void*)(this_obj & (~1));
12284         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12285         AcceptChannel_free(this_obj_conv);
12286 }
12287
12288 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
12289         LDKAcceptChannel this_ptr_conv;
12290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12291         this_ptr_conv.is_owned = false;
12292         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12293         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
12294         return ret_arr;
12295 }
12296
12297 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12298         LDKAcceptChannel this_ptr_conv;
12299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12300         this_ptr_conv.is_owned = false;
12301         LDKThirtyTwoBytes val_ref;
12302         CHECK(*((uint32_t*)val) == 32);
12303         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12304         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12305 }
12306
12307 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
12308         LDKAcceptChannel this_ptr_conv;
12309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12310         this_ptr_conv.is_owned = false;
12311         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
12312         return ret_val;
12313 }
12314
12315 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
12316         LDKAcceptChannel this_ptr_conv;
12317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12318         this_ptr_conv.is_owned = false;
12319         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12320 }
12321
12322 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12323         LDKAcceptChannel this_ptr_conv;
12324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12325         this_ptr_conv.is_owned = false;
12326         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12327         return ret_val;
12328 }
12329
12330 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12331         LDKAcceptChannel this_ptr_conv;
12332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12333         this_ptr_conv.is_owned = false;
12334         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12335 }
12336
12337 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
12338         LDKAcceptChannel this_ptr_conv;
12339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12340         this_ptr_conv.is_owned = false;
12341         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12342         return ret_val;
12343 }
12344
12345 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12346         LDKAcceptChannel this_ptr_conv;
12347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12348         this_ptr_conv.is_owned = false;
12349         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12350 }
12351
12352 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
12353         LDKAcceptChannel this_ptr_conv;
12354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12355         this_ptr_conv.is_owned = false;
12356         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
12357         return ret_val;
12358 }
12359
12360 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12361         LDKAcceptChannel this_ptr_conv;
12362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12363         this_ptr_conv.is_owned = false;
12364         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12365 }
12366
12367 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
12368         LDKAcceptChannel this_ptr_conv;
12369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12370         this_ptr_conv.is_owned = false;
12371         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
12372         return ret_val;
12373 }
12374
12375 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
12376         LDKAcceptChannel this_ptr_conv;
12377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12378         this_ptr_conv.is_owned = false;
12379         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
12380 }
12381
12382 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
12383         LDKAcceptChannel this_ptr_conv;
12384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12385         this_ptr_conv.is_owned = false;
12386         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
12387         return ret_val;
12388 }
12389
12390 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12391         LDKAcceptChannel this_ptr_conv;
12392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12393         this_ptr_conv.is_owned = false;
12394         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
12395 }
12396
12397 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12398         LDKAcceptChannel this_ptr_conv;
12399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12400         this_ptr_conv.is_owned = false;
12401         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
12402         return ret_val;
12403 }
12404
12405 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12406         LDKAcceptChannel this_ptr_conv;
12407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12408         this_ptr_conv.is_owned = false;
12409         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12410 }
12411
12412 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
12413         LDKAcceptChannel this_ptr_conv;
12414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12415         this_ptr_conv.is_owned = false;
12416         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12417         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12418         return ret_arr;
12419 }
12420
12421 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12422         LDKAcceptChannel this_ptr_conv;
12423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12424         this_ptr_conv.is_owned = false;
12425         LDKPublicKey val_ref;
12426         CHECK(*((uint32_t*)val) == 33);
12427         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12428         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12429 }
12430
12431 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
12432         LDKAcceptChannel this_ptr_conv;
12433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12434         this_ptr_conv.is_owned = false;
12435         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12436         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12437         return ret_arr;
12438 }
12439
12440 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12441         LDKAcceptChannel this_ptr_conv;
12442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12443         this_ptr_conv.is_owned = false;
12444         LDKPublicKey val_ref;
12445         CHECK(*((uint32_t*)val) == 33);
12446         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12447         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12448 }
12449
12450 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
12451         LDKAcceptChannel this_ptr_conv;
12452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12453         this_ptr_conv.is_owned = false;
12454         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12455         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12456         return ret_arr;
12457 }
12458
12459 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12460         LDKAcceptChannel this_ptr_conv;
12461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12462         this_ptr_conv.is_owned = false;
12463         LDKPublicKey val_ref;
12464         CHECK(*((uint32_t*)val) == 33);
12465         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12466         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
12467 }
12468
12469 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12470         LDKAcceptChannel this_ptr_conv;
12471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12472         this_ptr_conv.is_owned = false;
12473         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12474         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12475         return ret_arr;
12476 }
12477
12478 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12479         LDKAcceptChannel this_ptr_conv;
12480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12481         this_ptr_conv.is_owned = false;
12482         LDKPublicKey val_ref;
12483         CHECK(*((uint32_t*)val) == 33);
12484         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12485         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12486 }
12487
12488 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
12489         LDKAcceptChannel this_ptr_conv;
12490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12491         this_ptr_conv.is_owned = false;
12492         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12493         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12494         return ret_arr;
12495 }
12496
12497 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12498         LDKAcceptChannel this_ptr_conv;
12499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12500         this_ptr_conv.is_owned = false;
12501         LDKPublicKey val_ref;
12502         CHECK(*((uint32_t*)val) == 33);
12503         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12504         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12505 }
12506
12507 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12508         LDKAcceptChannel this_ptr_conv;
12509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12510         this_ptr_conv.is_owned = false;
12511         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12512         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12513         return ret_arr;
12514 }
12515
12516 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12517         LDKAcceptChannel this_ptr_conv;
12518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12519         this_ptr_conv.is_owned = false;
12520         LDKPublicKey val_ref;
12521         CHECK(*((uint32_t*)val) == 33);
12522         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12523         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12524 }
12525
12526 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
12527         LDKAcceptChannel orig_conv;
12528         orig_conv.inner = (void*)(orig & (~1));
12529         orig_conv.is_owned = false;
12530         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
12531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12533         long ret_ref = (long)ret_var.inner;
12534         if (ret_var.is_owned) {
12535                 ret_ref |= 1;
12536         }
12537         return ret_ref;
12538 }
12539
12540 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
12541         LDKFundingCreated this_obj_conv;
12542         this_obj_conv.inner = (void*)(this_obj & (~1));
12543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12544         FundingCreated_free(this_obj_conv);
12545 }
12546
12547 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
12548         LDKFundingCreated this_ptr_conv;
12549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12550         this_ptr_conv.is_owned = false;
12551         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12552         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
12553         return ret_arr;
12554 }
12555
12556 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12557         LDKFundingCreated this_ptr_conv;
12558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12559         this_ptr_conv.is_owned = false;
12560         LDKThirtyTwoBytes val_ref;
12561         CHECK(*((uint32_t*)val) == 32);
12562         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12563         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
12564 }
12565
12566 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
12567         LDKFundingCreated this_ptr_conv;
12568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12569         this_ptr_conv.is_owned = false;
12570         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12571         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
12572         return ret_arr;
12573 }
12574
12575 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
12576         LDKFundingCreated this_ptr_conv;
12577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12578         this_ptr_conv.is_owned = false;
12579         LDKThirtyTwoBytes val_ref;
12580         CHECK(*((uint32_t*)val) == 32);
12581         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12582         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
12583 }
12584
12585 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
12586         LDKFundingCreated this_ptr_conv;
12587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12588         this_ptr_conv.is_owned = false;
12589         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
12590         return ret_val;
12591 }
12592
12593 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
12594         LDKFundingCreated this_ptr_conv;
12595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12596         this_ptr_conv.is_owned = false;
12597         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
12598 }
12599
12600 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
12601         LDKFundingCreated this_ptr_conv;
12602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12603         this_ptr_conv.is_owned = false;
12604         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12605         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
12606         return ret_arr;
12607 }
12608
12609 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
12610         LDKFundingCreated this_ptr_conv;
12611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12612         this_ptr_conv.is_owned = false;
12613         LDKSignature val_ref;
12614         CHECK(*((uint32_t*)val) == 64);
12615         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12616         FundingCreated_set_signature(&this_ptr_conv, val_ref);
12617 }
12618
12619 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
12620         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
12621         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
12622         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
12623         LDKThirtyTwoBytes funding_txid_arg_ref;
12624         CHECK(*((uint32_t*)funding_txid_arg) == 32);
12625         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
12626         LDKSignature signature_arg_ref;
12627         CHECK(*((uint32_t*)signature_arg) == 64);
12628         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12629         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
12630         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12631         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12632         long ret_ref = (long)ret_var.inner;
12633         if (ret_var.is_owned) {
12634                 ret_ref |= 1;
12635         }
12636         return ret_ref;
12637 }
12638
12639 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
12640         LDKFundingCreated orig_conv;
12641         orig_conv.inner = (void*)(orig & (~1));
12642         orig_conv.is_owned = false;
12643         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
12644         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12645         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12646         long ret_ref = (long)ret_var.inner;
12647         if (ret_var.is_owned) {
12648                 ret_ref |= 1;
12649         }
12650         return ret_ref;
12651 }
12652
12653 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
12654         LDKFundingSigned this_obj_conv;
12655         this_obj_conv.inner = (void*)(this_obj & (~1));
12656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12657         FundingSigned_free(this_obj_conv);
12658 }
12659
12660 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
12661         LDKFundingSigned this_ptr_conv;
12662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12663         this_ptr_conv.is_owned = false;
12664         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12665         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
12666         return ret_arr;
12667 }
12668
12669 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12670         LDKFundingSigned this_ptr_conv;
12671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12672         this_ptr_conv.is_owned = false;
12673         LDKThirtyTwoBytes val_ref;
12674         CHECK(*((uint32_t*)val) == 32);
12675         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12676         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
12677 }
12678
12679 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
12680         LDKFundingSigned this_ptr_conv;
12681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12682         this_ptr_conv.is_owned = false;
12683         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12684         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12685         return ret_arr;
12686 }
12687
12688 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12689         LDKFundingSigned this_ptr_conv;
12690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12691         this_ptr_conv.is_owned = false;
12692         LDKSignature val_ref;
12693         CHECK(*((uint32_t*)val) == 64);
12694         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12695         FundingSigned_set_signature(&this_ptr_conv, val_ref);
12696 }
12697
12698 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
12699         LDKThirtyTwoBytes channel_id_arg_ref;
12700         CHECK(*((uint32_t*)channel_id_arg) == 32);
12701         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12702         LDKSignature signature_arg_ref;
12703         CHECK(*((uint32_t*)signature_arg) == 64);
12704         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12705         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
12706         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12707         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12708         long ret_ref = (long)ret_var.inner;
12709         if (ret_var.is_owned) {
12710                 ret_ref |= 1;
12711         }
12712         return ret_ref;
12713 }
12714
12715 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
12716         LDKFundingSigned orig_conv;
12717         orig_conv.inner = (void*)(orig & (~1));
12718         orig_conv.is_owned = false;
12719         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
12720         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12721         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12722         long ret_ref = (long)ret_var.inner;
12723         if (ret_var.is_owned) {
12724                 ret_ref |= 1;
12725         }
12726         return ret_ref;
12727 }
12728
12729 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
12730         LDKFundingLocked this_obj_conv;
12731         this_obj_conv.inner = (void*)(this_obj & (~1));
12732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12733         FundingLocked_free(this_obj_conv);
12734 }
12735
12736 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
12737         LDKFundingLocked this_ptr_conv;
12738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12739         this_ptr_conv.is_owned = false;
12740         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12741         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
12742         return ret_arr;
12743 }
12744
12745 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12746         LDKFundingLocked this_ptr_conv;
12747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12748         this_ptr_conv.is_owned = false;
12749         LDKThirtyTwoBytes val_ref;
12750         CHECK(*((uint32_t*)val) == 32);
12751         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12752         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
12753 }
12754
12755 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
12756         LDKFundingLocked this_ptr_conv;
12757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12758         this_ptr_conv.is_owned = false;
12759         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12760         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12761         return ret_arr;
12762 }
12763
12764 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12765         LDKFundingLocked this_ptr_conv;
12766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12767         this_ptr_conv.is_owned = false;
12768         LDKPublicKey val_ref;
12769         CHECK(*((uint32_t*)val) == 33);
12770         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12771         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
12772 }
12773
12774 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
12775         LDKThirtyTwoBytes channel_id_arg_ref;
12776         CHECK(*((uint32_t*)channel_id_arg) == 32);
12777         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12778         LDKPublicKey next_per_commitment_point_arg_ref;
12779         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
12780         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
12781         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
12782         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12783         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12784         long ret_ref = (long)ret_var.inner;
12785         if (ret_var.is_owned) {
12786                 ret_ref |= 1;
12787         }
12788         return ret_ref;
12789 }
12790
12791 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
12792         LDKFundingLocked orig_conv;
12793         orig_conv.inner = (void*)(orig & (~1));
12794         orig_conv.is_owned = false;
12795         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
12796         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12797         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12798         long ret_ref = (long)ret_var.inner;
12799         if (ret_var.is_owned) {
12800                 ret_ref |= 1;
12801         }
12802         return ret_ref;
12803 }
12804
12805 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
12806         LDKShutdown this_obj_conv;
12807         this_obj_conv.inner = (void*)(this_obj & (~1));
12808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12809         Shutdown_free(this_obj_conv);
12810 }
12811
12812 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
12813         LDKShutdown this_ptr_conv;
12814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12815         this_ptr_conv.is_owned = false;
12816         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12817         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
12818         return ret_arr;
12819 }
12820
12821 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12822         LDKShutdown this_ptr_conv;
12823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12824         this_ptr_conv.is_owned = false;
12825         LDKThirtyTwoBytes val_ref;
12826         CHECK(*((uint32_t*)val) == 32);
12827         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12828         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
12829 }
12830
12831 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
12832         LDKShutdown this_ptr_conv;
12833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12834         this_ptr_conv.is_owned = false;
12835         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
12836         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12837         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12838         return ret_arr;
12839 }
12840
12841 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
12842         LDKShutdown this_ptr_conv;
12843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12844         this_ptr_conv.is_owned = false;
12845         LDKCVec_u8Z val_ref;
12846         val_ref.datalen = *((uint32_t*)val);
12847         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12848         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
12849         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
12850 }
12851
12852 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
12853         LDKThirtyTwoBytes channel_id_arg_ref;
12854         CHECK(*((uint32_t*)channel_id_arg) == 32);
12855         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12856         LDKCVec_u8Z scriptpubkey_arg_ref;
12857         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
12858         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12859         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
12860         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
12861         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12862         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12863         long ret_ref = (long)ret_var.inner;
12864         if (ret_var.is_owned) {
12865                 ret_ref |= 1;
12866         }
12867         return ret_ref;
12868 }
12869
12870 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
12871         LDKShutdown orig_conv;
12872         orig_conv.inner = (void*)(orig & (~1));
12873         orig_conv.is_owned = false;
12874         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
12875         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12876         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12877         long ret_ref = (long)ret_var.inner;
12878         if (ret_var.is_owned) {
12879                 ret_ref |= 1;
12880         }
12881         return ret_ref;
12882 }
12883
12884 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
12885         LDKClosingSigned this_obj_conv;
12886         this_obj_conv.inner = (void*)(this_obj & (~1));
12887         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12888         ClosingSigned_free(this_obj_conv);
12889 }
12890
12891 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
12892         LDKClosingSigned this_ptr_conv;
12893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12894         this_ptr_conv.is_owned = false;
12895         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12896         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
12897         return ret_arr;
12898 }
12899
12900 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12901         LDKClosingSigned this_ptr_conv;
12902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12903         this_ptr_conv.is_owned = false;
12904         LDKThirtyTwoBytes val_ref;
12905         CHECK(*((uint32_t*)val) == 32);
12906         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12907         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
12908 }
12909
12910 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
12911         LDKClosingSigned this_ptr_conv;
12912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12913         this_ptr_conv.is_owned = false;
12914         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
12915         return ret_val;
12916 }
12917
12918 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
12919         LDKClosingSigned this_ptr_conv;
12920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12921         this_ptr_conv.is_owned = false;
12922         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
12923 }
12924
12925 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
12926         LDKClosingSigned this_ptr_conv;
12927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12928         this_ptr_conv.is_owned = false;
12929         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12930         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12931         return ret_arr;
12932 }
12933
12934 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12935         LDKClosingSigned this_ptr_conv;
12936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12937         this_ptr_conv.is_owned = false;
12938         LDKSignature val_ref;
12939         CHECK(*((uint32_t*)val) == 64);
12940         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12941         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
12942 }
12943
12944 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
12945         LDKThirtyTwoBytes channel_id_arg_ref;
12946         CHECK(*((uint32_t*)channel_id_arg) == 32);
12947         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12948         LDKSignature signature_arg_ref;
12949         CHECK(*((uint32_t*)signature_arg) == 64);
12950         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12951         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
12952         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12953         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12954         long ret_ref = (long)ret_var.inner;
12955         if (ret_var.is_owned) {
12956                 ret_ref |= 1;
12957         }
12958         return ret_ref;
12959 }
12960
12961 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
12962         LDKClosingSigned orig_conv;
12963         orig_conv.inner = (void*)(orig & (~1));
12964         orig_conv.is_owned = false;
12965         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
12966         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12967         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12968         long ret_ref = (long)ret_var.inner;
12969         if (ret_var.is_owned) {
12970                 ret_ref |= 1;
12971         }
12972         return ret_ref;
12973 }
12974
12975 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
12976         LDKUpdateAddHTLC this_obj_conv;
12977         this_obj_conv.inner = (void*)(this_obj & (~1));
12978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12979         UpdateAddHTLC_free(this_obj_conv);
12980 }
12981
12982 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
12983         LDKUpdateAddHTLC this_ptr_conv;
12984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12985         this_ptr_conv.is_owned = false;
12986         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12987         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
12988         return ret_arr;
12989 }
12990
12991 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12992         LDKUpdateAddHTLC this_ptr_conv;
12993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12994         this_ptr_conv.is_owned = false;
12995         LDKThirtyTwoBytes val_ref;
12996         CHECK(*((uint32_t*)val) == 32);
12997         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12998         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
12999 }
13000
13001 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
13002         LDKUpdateAddHTLC this_ptr_conv;
13003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13004         this_ptr_conv.is_owned = false;
13005         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
13006         return ret_val;
13007 }
13008
13009 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13010         LDKUpdateAddHTLC this_ptr_conv;
13011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13012         this_ptr_conv.is_owned = false;
13013         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
13014 }
13015
13016 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
13017         LDKUpdateAddHTLC this_ptr_conv;
13018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13019         this_ptr_conv.is_owned = false;
13020         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
13021         return ret_val;
13022 }
13023
13024 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
13025         LDKUpdateAddHTLC this_ptr_conv;
13026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13027         this_ptr_conv.is_owned = false;
13028         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
13029 }
13030
13031 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
13032         LDKUpdateAddHTLC this_ptr_conv;
13033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13034         this_ptr_conv.is_owned = false;
13035         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13036         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
13037         return ret_arr;
13038 }
13039
13040 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
13041         LDKUpdateAddHTLC this_ptr_conv;
13042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13043         this_ptr_conv.is_owned = false;
13044         LDKThirtyTwoBytes val_ref;
13045         CHECK(*((uint32_t*)val) == 32);
13046         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13047         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
13048 }
13049
13050 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
13051         LDKUpdateAddHTLC this_ptr_conv;
13052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13053         this_ptr_conv.is_owned = false;
13054         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
13055         return ret_val;
13056 }
13057
13058 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
13059         LDKUpdateAddHTLC this_ptr_conv;
13060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13061         this_ptr_conv.is_owned = false;
13062         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
13063 }
13064
13065 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
13066         LDKUpdateAddHTLC orig_conv;
13067         orig_conv.inner = (void*)(orig & (~1));
13068         orig_conv.is_owned = false;
13069         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
13070         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13071         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13072         long ret_ref = (long)ret_var.inner;
13073         if (ret_var.is_owned) {
13074                 ret_ref |= 1;
13075         }
13076         return ret_ref;
13077 }
13078
13079 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
13080         LDKUpdateFulfillHTLC this_obj_conv;
13081         this_obj_conv.inner = (void*)(this_obj & (~1));
13082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13083         UpdateFulfillHTLC_free(this_obj_conv);
13084 }
13085
13086 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
13087         LDKUpdateFulfillHTLC this_ptr_conv;
13088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13089         this_ptr_conv.is_owned = false;
13090         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13091         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
13092         return ret_arr;
13093 }
13094
13095 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13096         LDKUpdateFulfillHTLC this_ptr_conv;
13097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13098         this_ptr_conv.is_owned = false;
13099         LDKThirtyTwoBytes val_ref;
13100         CHECK(*((uint32_t*)val) == 32);
13101         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13102         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
13103 }
13104
13105 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
13106         LDKUpdateFulfillHTLC this_ptr_conv;
13107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13108         this_ptr_conv.is_owned = false;
13109         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
13110         return ret_val;
13111 }
13112
13113 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13114         LDKUpdateFulfillHTLC this_ptr_conv;
13115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13116         this_ptr_conv.is_owned = false;
13117         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
13118 }
13119
13120 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
13121         LDKUpdateFulfillHTLC this_ptr_conv;
13122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13123         this_ptr_conv.is_owned = false;
13124         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13125         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
13126         return ret_arr;
13127 }
13128
13129 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
13130         LDKUpdateFulfillHTLC this_ptr_conv;
13131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13132         this_ptr_conv.is_owned = false;
13133         LDKThirtyTwoBytes val_ref;
13134         CHECK(*((uint32_t*)val) == 32);
13135         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13136         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
13137 }
13138
13139 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
13140         LDKThirtyTwoBytes channel_id_arg_ref;
13141         CHECK(*((uint32_t*)channel_id_arg) == 32);
13142         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13143         LDKThirtyTwoBytes payment_preimage_arg_ref;
13144         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
13145         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
13146         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
13147         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13148         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13149         long ret_ref = (long)ret_var.inner;
13150         if (ret_var.is_owned) {
13151                 ret_ref |= 1;
13152         }
13153         return ret_ref;
13154 }
13155
13156 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
13157         LDKUpdateFulfillHTLC orig_conv;
13158         orig_conv.inner = (void*)(orig & (~1));
13159         orig_conv.is_owned = false;
13160         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
13161         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13162         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13163         long ret_ref = (long)ret_var.inner;
13164         if (ret_var.is_owned) {
13165                 ret_ref |= 1;
13166         }
13167         return ret_ref;
13168 }
13169
13170 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
13171         LDKUpdateFailHTLC this_obj_conv;
13172         this_obj_conv.inner = (void*)(this_obj & (~1));
13173         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13174         UpdateFailHTLC_free(this_obj_conv);
13175 }
13176
13177 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
13178         LDKUpdateFailHTLC this_ptr_conv;
13179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13180         this_ptr_conv.is_owned = false;
13181         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13182         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
13183         return ret_arr;
13184 }
13185
13186 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13187         LDKUpdateFailHTLC this_ptr_conv;
13188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13189         this_ptr_conv.is_owned = false;
13190         LDKThirtyTwoBytes val_ref;
13191         CHECK(*((uint32_t*)val) == 32);
13192         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13193         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
13194 }
13195
13196 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
13197         LDKUpdateFailHTLC this_ptr_conv;
13198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13199         this_ptr_conv.is_owned = false;
13200         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
13201         return ret_val;
13202 }
13203
13204 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13205         LDKUpdateFailHTLC this_ptr_conv;
13206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13207         this_ptr_conv.is_owned = false;
13208         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
13209 }
13210
13211 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
13212         LDKUpdateFailHTLC orig_conv;
13213         orig_conv.inner = (void*)(orig & (~1));
13214         orig_conv.is_owned = false;
13215         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
13216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13218         long ret_ref = (long)ret_var.inner;
13219         if (ret_var.is_owned) {
13220                 ret_ref |= 1;
13221         }
13222         return ret_ref;
13223 }
13224
13225 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
13226         LDKUpdateFailMalformedHTLC this_obj_conv;
13227         this_obj_conv.inner = (void*)(this_obj & (~1));
13228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13229         UpdateFailMalformedHTLC_free(this_obj_conv);
13230 }
13231
13232 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
13233         LDKUpdateFailMalformedHTLC this_ptr_conv;
13234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13235         this_ptr_conv.is_owned = false;
13236         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13237         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
13238         return ret_arr;
13239 }
13240
13241 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13242         LDKUpdateFailMalformedHTLC this_ptr_conv;
13243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13244         this_ptr_conv.is_owned = false;
13245         LDKThirtyTwoBytes val_ref;
13246         CHECK(*((uint32_t*)val) == 32);
13247         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13248         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
13249 }
13250
13251 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
13252         LDKUpdateFailMalformedHTLC this_ptr_conv;
13253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13254         this_ptr_conv.is_owned = false;
13255         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
13256         return ret_val;
13257 }
13258
13259 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13260         LDKUpdateFailMalformedHTLC this_ptr_conv;
13261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13262         this_ptr_conv.is_owned = false;
13263         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
13264 }
13265
13266 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
13267         LDKUpdateFailMalformedHTLC this_ptr_conv;
13268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13269         this_ptr_conv.is_owned = false;
13270         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
13271         return ret_val;
13272 }
13273
13274 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
13275         LDKUpdateFailMalformedHTLC this_ptr_conv;
13276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13277         this_ptr_conv.is_owned = false;
13278         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
13279 }
13280
13281 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
13282         LDKUpdateFailMalformedHTLC orig_conv;
13283         orig_conv.inner = (void*)(orig & (~1));
13284         orig_conv.is_owned = false;
13285         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
13286         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13287         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13288         long ret_ref = (long)ret_var.inner;
13289         if (ret_var.is_owned) {
13290                 ret_ref |= 1;
13291         }
13292         return ret_ref;
13293 }
13294
13295 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
13296         LDKCommitmentSigned this_obj_conv;
13297         this_obj_conv.inner = (void*)(this_obj & (~1));
13298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13299         CommitmentSigned_free(this_obj_conv);
13300 }
13301
13302 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
13303         LDKCommitmentSigned this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13307         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
13308         return ret_arr;
13309 }
13310
13311 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13312         LDKCommitmentSigned this_ptr_conv;
13313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13314         this_ptr_conv.is_owned = false;
13315         LDKThirtyTwoBytes val_ref;
13316         CHECK(*((uint32_t*)val) == 32);
13317         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13318         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
13319 }
13320
13321 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
13322         LDKCommitmentSigned this_ptr_conv;
13323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13324         this_ptr_conv.is_owned = false;
13325         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13326         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
13327         return ret_arr;
13328 }
13329
13330 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
13331         LDKCommitmentSigned this_ptr_conv;
13332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13333         this_ptr_conv.is_owned = false;
13334         LDKSignature val_ref;
13335         CHECK(*((uint32_t*)val) == 64);
13336         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13337         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
13338 }
13339
13340 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
13341         LDKCommitmentSigned this_ptr_conv;
13342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13343         this_ptr_conv.is_owned = false;
13344         LDKCVec_SignatureZ val_constr;
13345         val_constr.datalen = *((uint32_t*)val);
13346         if (val_constr.datalen > 0)
13347                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13348         else
13349                 val_constr.data = NULL;
13350         int8_tArray* val_vals = (int8_tArray*)(val + 4);
13351         for (size_t m = 0; m < val_constr.datalen; m++) {
13352                 int8_tArray val_conv_12 = val_vals[m];
13353                 LDKSignature val_conv_12_ref;
13354                 CHECK(*((uint32_t*)val_conv_12) == 64);
13355                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
13356                 val_constr.data[m] = val_conv_12_ref;
13357         }
13358         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
13359 }
13360
13361 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
13362         LDKThirtyTwoBytes channel_id_arg_ref;
13363         CHECK(*((uint32_t*)channel_id_arg) == 32);
13364         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13365         LDKSignature signature_arg_ref;
13366         CHECK(*((uint32_t*)signature_arg) == 64);
13367         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13368         LDKCVec_SignatureZ htlc_signatures_arg_constr;
13369         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
13370         if (htlc_signatures_arg_constr.datalen > 0)
13371                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13372         else
13373                 htlc_signatures_arg_constr.data = NULL;
13374         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
13375         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
13376                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
13377                 LDKSignature htlc_signatures_arg_conv_12_ref;
13378                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
13379                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
13380                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
13381         }
13382         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
13383         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13384         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13385         long ret_ref = (long)ret_var.inner;
13386         if (ret_var.is_owned) {
13387                 ret_ref |= 1;
13388         }
13389         return ret_ref;
13390 }
13391
13392 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
13393         LDKCommitmentSigned orig_conv;
13394         orig_conv.inner = (void*)(orig & (~1));
13395         orig_conv.is_owned = false;
13396         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
13397         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13398         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13399         long ret_ref = (long)ret_var.inner;
13400         if (ret_var.is_owned) {
13401                 ret_ref |= 1;
13402         }
13403         return ret_ref;
13404 }
13405
13406 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
13407         LDKRevokeAndACK this_obj_conv;
13408         this_obj_conv.inner = (void*)(this_obj & (~1));
13409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13410         RevokeAndACK_free(this_obj_conv);
13411 }
13412
13413 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
13414         LDKRevokeAndACK this_ptr_conv;
13415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13416         this_ptr_conv.is_owned = false;
13417         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13418         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
13419         return ret_arr;
13420 }
13421
13422 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13423         LDKRevokeAndACK this_ptr_conv;
13424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13425         this_ptr_conv.is_owned = false;
13426         LDKThirtyTwoBytes val_ref;
13427         CHECK(*((uint32_t*)val) == 32);
13428         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13429         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
13430 }
13431
13432 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
13433         LDKRevokeAndACK this_ptr_conv;
13434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13435         this_ptr_conv.is_owned = false;
13436         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13437         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
13438         return ret_arr;
13439 }
13440
13441 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13442         LDKRevokeAndACK this_ptr_conv;
13443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13444         this_ptr_conv.is_owned = false;
13445         LDKThirtyTwoBytes val_ref;
13446         CHECK(*((uint32_t*)val) == 32);
13447         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13448         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
13449 }
13450
13451 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
13452         LDKRevokeAndACK this_ptr_conv;
13453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13454         this_ptr_conv.is_owned = false;
13455         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13456         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13457         return ret_arr;
13458 }
13459
13460 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13461         LDKRevokeAndACK this_ptr_conv;
13462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13463         this_ptr_conv.is_owned = false;
13464         LDKPublicKey val_ref;
13465         CHECK(*((uint32_t*)val) == 33);
13466         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13467         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13468 }
13469
13470 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
13471         LDKThirtyTwoBytes channel_id_arg_ref;
13472         CHECK(*((uint32_t*)channel_id_arg) == 32);
13473         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13474         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
13475         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
13476         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
13477         LDKPublicKey next_per_commitment_point_arg_ref;
13478         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
13479         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
13480         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
13481         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13482         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13483         long ret_ref = (long)ret_var.inner;
13484         if (ret_var.is_owned) {
13485                 ret_ref |= 1;
13486         }
13487         return ret_ref;
13488 }
13489
13490 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
13491         LDKRevokeAndACK orig_conv;
13492         orig_conv.inner = (void*)(orig & (~1));
13493         orig_conv.is_owned = false;
13494         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
13495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13497         long ret_ref = (long)ret_var.inner;
13498         if (ret_var.is_owned) {
13499                 ret_ref |= 1;
13500         }
13501         return ret_ref;
13502 }
13503
13504 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
13505         LDKUpdateFee this_obj_conv;
13506         this_obj_conv.inner = (void*)(this_obj & (~1));
13507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13508         UpdateFee_free(this_obj_conv);
13509 }
13510
13511 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
13512         LDKUpdateFee this_ptr_conv;
13513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13514         this_ptr_conv.is_owned = false;
13515         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13516         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
13517         return ret_arr;
13518 }
13519
13520 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13521         LDKUpdateFee this_ptr_conv;
13522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13523         this_ptr_conv.is_owned = false;
13524         LDKThirtyTwoBytes val_ref;
13525         CHECK(*((uint32_t*)val) == 32);
13526         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13527         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
13528 }
13529
13530 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
13531         LDKUpdateFee this_ptr_conv;
13532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13533         this_ptr_conv.is_owned = false;
13534         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
13535         return ret_val;
13536 }
13537
13538 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
13539         LDKUpdateFee this_ptr_conv;
13540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13541         this_ptr_conv.is_owned = false;
13542         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
13543 }
13544
13545 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
13546         LDKThirtyTwoBytes channel_id_arg_ref;
13547         CHECK(*((uint32_t*)channel_id_arg) == 32);
13548         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13549         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
13550         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13551         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13552         long ret_ref = (long)ret_var.inner;
13553         if (ret_var.is_owned) {
13554                 ret_ref |= 1;
13555         }
13556         return ret_ref;
13557 }
13558
13559 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
13560         LDKUpdateFee orig_conv;
13561         orig_conv.inner = (void*)(orig & (~1));
13562         orig_conv.is_owned = false;
13563         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
13564         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13565         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13566         long ret_ref = (long)ret_var.inner;
13567         if (ret_var.is_owned) {
13568                 ret_ref |= 1;
13569         }
13570         return ret_ref;
13571 }
13572
13573 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
13574         LDKDataLossProtect this_obj_conv;
13575         this_obj_conv.inner = (void*)(this_obj & (~1));
13576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13577         DataLossProtect_free(this_obj_conv);
13578 }
13579
13580 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
13581         LDKDataLossProtect this_ptr_conv;
13582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13583         this_ptr_conv.is_owned = false;
13584         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13585         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
13586         return ret_arr;
13587 }
13588
13589 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13590         LDKDataLossProtect this_ptr_conv;
13591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13592         this_ptr_conv.is_owned = false;
13593         LDKThirtyTwoBytes val_ref;
13594         CHECK(*((uint32_t*)val) == 32);
13595         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13596         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
13597 }
13598
13599 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
13600         LDKDataLossProtect this_ptr_conv;
13601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13602         this_ptr_conv.is_owned = false;
13603         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13604         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13605         return ret_arr;
13606 }
13607
13608 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13609         LDKDataLossProtect this_ptr_conv;
13610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13611         this_ptr_conv.is_owned = false;
13612         LDKPublicKey val_ref;
13613         CHECK(*((uint32_t*)val) == 33);
13614         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13615         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
13616 }
13617
13618 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
13619         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
13620         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
13621         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
13622         LDKPublicKey my_current_per_commitment_point_arg_ref;
13623         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
13624         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
13625         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
13626         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13627         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13628         long ret_ref = (long)ret_var.inner;
13629         if (ret_var.is_owned) {
13630                 ret_ref |= 1;
13631         }
13632         return ret_ref;
13633 }
13634
13635 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
13636         LDKDataLossProtect orig_conv;
13637         orig_conv.inner = (void*)(orig & (~1));
13638         orig_conv.is_owned = false;
13639         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
13640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13642         long ret_ref = (long)ret_var.inner;
13643         if (ret_var.is_owned) {
13644                 ret_ref |= 1;
13645         }
13646         return ret_ref;
13647 }
13648
13649 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
13650         LDKChannelReestablish this_obj_conv;
13651         this_obj_conv.inner = (void*)(this_obj & (~1));
13652         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13653         ChannelReestablish_free(this_obj_conv);
13654 }
13655
13656 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
13657         LDKChannelReestablish this_ptr_conv;
13658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13659         this_ptr_conv.is_owned = false;
13660         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13661         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
13662         return ret_arr;
13663 }
13664
13665 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13666         LDKChannelReestablish this_ptr_conv;
13667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13668         this_ptr_conv.is_owned = false;
13669         LDKThirtyTwoBytes val_ref;
13670         CHECK(*((uint32_t*)val) == 32);
13671         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13672         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
13673 }
13674
13675 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
13676         LDKChannelReestablish this_ptr_conv;
13677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13678         this_ptr_conv.is_owned = false;
13679         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
13680         return ret_val;
13681 }
13682
13683 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
13684         LDKChannelReestablish this_ptr_conv;
13685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13686         this_ptr_conv.is_owned = false;
13687         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
13688 }
13689
13690 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
13691         LDKChannelReestablish this_ptr_conv;
13692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13693         this_ptr_conv.is_owned = false;
13694         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
13695         return ret_val;
13696 }
13697
13698 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
13699         LDKChannelReestablish this_ptr_conv;
13700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13701         this_ptr_conv.is_owned = false;
13702         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
13703 }
13704
13705 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
13706         LDKChannelReestablish orig_conv;
13707         orig_conv.inner = (void*)(orig & (~1));
13708         orig_conv.is_owned = false;
13709         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
13710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13712         long ret_ref = (long)ret_var.inner;
13713         if (ret_var.is_owned) {
13714                 ret_ref |= 1;
13715         }
13716         return ret_ref;
13717 }
13718
13719 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
13720         LDKAnnouncementSignatures this_obj_conv;
13721         this_obj_conv.inner = (void*)(this_obj & (~1));
13722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13723         AnnouncementSignatures_free(this_obj_conv);
13724 }
13725
13726 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
13727         LDKAnnouncementSignatures this_ptr_conv;
13728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13729         this_ptr_conv.is_owned = false;
13730         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13731         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
13732         return ret_arr;
13733 }
13734
13735 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13736         LDKAnnouncementSignatures this_ptr_conv;
13737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13738         this_ptr_conv.is_owned = false;
13739         LDKThirtyTwoBytes val_ref;
13740         CHECK(*((uint32_t*)val) == 32);
13741         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13742         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
13743 }
13744
13745 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
13746         LDKAnnouncementSignatures this_ptr_conv;
13747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13748         this_ptr_conv.is_owned = false;
13749         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
13750         return ret_val;
13751 }
13752
13753 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
13754         LDKAnnouncementSignatures this_ptr_conv;
13755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13756         this_ptr_conv.is_owned = false;
13757         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
13758 }
13759
13760 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
13761         LDKAnnouncementSignatures this_ptr_conv;
13762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13763         this_ptr_conv.is_owned = false;
13764         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13765         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
13766         return ret_arr;
13767 }
13768
13769 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
13770         LDKAnnouncementSignatures this_ptr_conv;
13771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13772         this_ptr_conv.is_owned = false;
13773         LDKSignature val_ref;
13774         CHECK(*((uint32_t*)val) == 64);
13775         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13776         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
13777 }
13778
13779 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
13780         LDKAnnouncementSignatures this_ptr_conv;
13781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13782         this_ptr_conv.is_owned = false;
13783         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13784         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
13785         return ret_arr;
13786 }
13787
13788 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
13789         LDKAnnouncementSignatures this_ptr_conv;
13790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13791         this_ptr_conv.is_owned = false;
13792         LDKSignature val_ref;
13793         CHECK(*((uint32_t*)val) == 64);
13794         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13795         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
13796 }
13797
13798 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
13799         LDKThirtyTwoBytes channel_id_arg_ref;
13800         CHECK(*((uint32_t*)channel_id_arg) == 32);
13801         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13802         LDKSignature node_signature_arg_ref;
13803         CHECK(*((uint32_t*)node_signature_arg) == 64);
13804         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
13805         LDKSignature bitcoin_signature_arg_ref;
13806         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
13807         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
13808         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
13809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13811         long ret_ref = (long)ret_var.inner;
13812         if (ret_var.is_owned) {
13813                 ret_ref |= 1;
13814         }
13815         return ret_ref;
13816 }
13817
13818 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
13819         LDKAnnouncementSignatures orig_conv;
13820         orig_conv.inner = (void*)(orig & (~1));
13821         orig_conv.is_owned = false;
13822         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
13823         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13824         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13825         long ret_ref = (long)ret_var.inner;
13826         if (ret_var.is_owned) {
13827                 ret_ref |= 1;
13828         }
13829         return ret_ref;
13830 }
13831
13832 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
13833         if ((this_ptr & 1) != 0) return;
13834         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
13835         FREE((void*)this_ptr);
13836         NetAddress_free(this_ptr_conv);
13837 }
13838
13839 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
13840         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
13841         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
13842         *ret_copy = NetAddress_clone(orig_conv);
13843         long ret_ref = (long)ret_copy;
13844         return ret_ref;
13845 }
13846
13847 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
13848         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
13849         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
13850         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13851         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13852         CVec_u8Z_free(ret_var);
13853         return ret_arr;
13854 }
13855
13856 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
13857         LDKu8slice ser_ref;
13858         ser_ref.datalen = *((uint32_t*)ser);
13859         ser_ref.data = (int8_t*)(ser + 4);
13860         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13861         *ret_conv = Result_read(ser_ref);
13862         return (long)ret_conv;
13863 }
13864
13865 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
13866         LDKUnsignedNodeAnnouncement this_obj_conv;
13867         this_obj_conv.inner = (void*)(this_obj & (~1));
13868         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13869         UnsignedNodeAnnouncement_free(this_obj_conv);
13870 }
13871
13872 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
13873         LDKUnsignedNodeAnnouncement this_ptr_conv;
13874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13875         this_ptr_conv.is_owned = false;
13876         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
13877         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13878         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13879         long ret_ref = (long)ret_var.inner;
13880         if (ret_var.is_owned) {
13881                 ret_ref |= 1;
13882         }
13883         return ret_ref;
13884 }
13885
13886 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
13887         LDKUnsignedNodeAnnouncement this_ptr_conv;
13888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13889         this_ptr_conv.is_owned = false;
13890         LDKNodeFeatures val_conv;
13891         val_conv.inner = (void*)(val & (~1));
13892         val_conv.is_owned = (val & 1) || (val == 0);
13893         val_conv = NodeFeatures_clone(&val_conv);
13894         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
13895 }
13896
13897 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
13898         LDKUnsignedNodeAnnouncement this_ptr_conv;
13899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13900         this_ptr_conv.is_owned = false;
13901         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
13902         return ret_val;
13903 }
13904
13905 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
13906         LDKUnsignedNodeAnnouncement this_ptr_conv;
13907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13908         this_ptr_conv.is_owned = false;
13909         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
13910 }
13911
13912 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
13913         LDKUnsignedNodeAnnouncement this_ptr_conv;
13914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13915         this_ptr_conv.is_owned = false;
13916         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13917         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
13918         return ret_arr;
13919 }
13920
13921 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
13922         LDKUnsignedNodeAnnouncement this_ptr_conv;
13923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13924         this_ptr_conv.is_owned = false;
13925         LDKPublicKey val_ref;
13926         CHECK(*((uint32_t*)val) == 33);
13927         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13928         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
13929 }
13930
13931 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
13932         LDKUnsignedNodeAnnouncement this_ptr_conv;
13933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13934         this_ptr_conv.is_owned = false;
13935         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
13936         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
13937         return ret_arr;
13938 }
13939
13940 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
13941         LDKUnsignedNodeAnnouncement this_ptr_conv;
13942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13943         this_ptr_conv.is_owned = false;
13944         LDKThreeBytes val_ref;
13945         CHECK(*((uint32_t*)val) == 3);
13946         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
13947         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
13948 }
13949
13950 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
13951         LDKUnsignedNodeAnnouncement this_ptr_conv;
13952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13953         this_ptr_conv.is_owned = false;
13954         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13955         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
13956         return ret_arr;
13957 }
13958
13959 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
13960         LDKUnsignedNodeAnnouncement this_ptr_conv;
13961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13962         this_ptr_conv.is_owned = false;
13963         LDKThirtyTwoBytes val_ref;
13964         CHECK(*((uint32_t*)val) == 32);
13965         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13966         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
13967 }
13968
13969 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
13970         LDKUnsignedNodeAnnouncement this_ptr_conv;
13971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13972         this_ptr_conv.is_owned = false;
13973         LDKCVec_NetAddressZ val_constr;
13974         val_constr.datalen = *((uint32_t*)val);
13975         if (val_constr.datalen > 0)
13976                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13977         else
13978                 val_constr.data = NULL;
13979         uint32_t* val_vals = (uint32_t*)(val + 4);
13980         for (size_t m = 0; m < val_constr.datalen; m++) {
13981                 uint32_t val_conv_12 = val_vals[m];
13982                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
13983                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
13984                 val_constr.data[m] = val_conv_12_conv;
13985         }
13986         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
13987 }
13988
13989 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
13990         LDKUnsignedNodeAnnouncement orig_conv;
13991         orig_conv.inner = (void*)(orig & (~1));
13992         orig_conv.is_owned = false;
13993         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
13994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13996         long ret_ref = (long)ret_var.inner;
13997         if (ret_var.is_owned) {
13998                 ret_ref |= 1;
13999         }
14000         return ret_ref;
14001 }
14002
14003 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
14004         LDKNodeAnnouncement this_obj_conv;
14005         this_obj_conv.inner = (void*)(this_obj & (~1));
14006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14007         NodeAnnouncement_free(this_obj_conv);
14008 }
14009
14010 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
14011         LDKNodeAnnouncement this_ptr_conv;
14012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14013         this_ptr_conv.is_owned = false;
14014         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14015         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
14016         return ret_arr;
14017 }
14018
14019 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
14020         LDKNodeAnnouncement this_ptr_conv;
14021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14022         this_ptr_conv.is_owned = false;
14023         LDKSignature val_ref;
14024         CHECK(*((uint32_t*)val) == 64);
14025         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14026         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
14027 }
14028
14029 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
14030         LDKNodeAnnouncement this_ptr_conv;
14031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14032         this_ptr_conv.is_owned = false;
14033         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
14034         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14035         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14036         long ret_ref = (long)ret_var.inner;
14037         if (ret_var.is_owned) {
14038                 ret_ref |= 1;
14039         }
14040         return ret_ref;
14041 }
14042
14043 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
14044         LDKNodeAnnouncement this_ptr_conv;
14045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14046         this_ptr_conv.is_owned = false;
14047         LDKUnsignedNodeAnnouncement val_conv;
14048         val_conv.inner = (void*)(val & (~1));
14049         val_conv.is_owned = (val & 1) || (val == 0);
14050         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
14051         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
14052 }
14053
14054 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
14055         LDKSignature signature_arg_ref;
14056         CHECK(*((uint32_t*)signature_arg) == 64);
14057         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14058         LDKUnsignedNodeAnnouncement contents_arg_conv;
14059         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14060         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14061         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
14062         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
14063         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14064         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14065         long ret_ref = (long)ret_var.inner;
14066         if (ret_var.is_owned) {
14067                 ret_ref |= 1;
14068         }
14069         return ret_ref;
14070 }
14071
14072 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
14073         LDKNodeAnnouncement orig_conv;
14074         orig_conv.inner = (void*)(orig & (~1));
14075         orig_conv.is_owned = false;
14076         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
14077         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14078         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14079         long ret_ref = (long)ret_var.inner;
14080         if (ret_var.is_owned) {
14081                 ret_ref |= 1;
14082         }
14083         return ret_ref;
14084 }
14085
14086 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
14087         LDKUnsignedChannelAnnouncement this_obj_conv;
14088         this_obj_conv.inner = (void*)(this_obj & (~1));
14089         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14090         UnsignedChannelAnnouncement_free(this_obj_conv);
14091 }
14092
14093 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
14094         LDKUnsignedChannelAnnouncement this_ptr_conv;
14095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14096         this_ptr_conv.is_owned = false;
14097         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
14098         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14099         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14100         long ret_ref = (long)ret_var.inner;
14101         if (ret_var.is_owned) {
14102                 ret_ref |= 1;
14103         }
14104         return ret_ref;
14105 }
14106
14107 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
14108         LDKUnsignedChannelAnnouncement this_ptr_conv;
14109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14110         this_ptr_conv.is_owned = false;
14111         LDKChannelFeatures val_conv;
14112         val_conv.inner = (void*)(val & (~1));
14113         val_conv.is_owned = (val & 1) || (val == 0);
14114         val_conv = ChannelFeatures_clone(&val_conv);
14115         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
14116 }
14117
14118 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
14119         LDKUnsignedChannelAnnouncement this_ptr_conv;
14120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14121         this_ptr_conv.is_owned = false;
14122         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14123         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
14124         return ret_arr;
14125 }
14126
14127 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14128         LDKUnsignedChannelAnnouncement this_ptr_conv;
14129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14130         this_ptr_conv.is_owned = false;
14131         LDKThirtyTwoBytes val_ref;
14132         CHECK(*((uint32_t*)val) == 32);
14133         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14134         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
14135 }
14136
14137 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
14138         LDKUnsignedChannelAnnouncement this_ptr_conv;
14139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14140         this_ptr_conv.is_owned = false;
14141         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
14142         return ret_val;
14143 }
14144
14145 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14146         LDKUnsignedChannelAnnouncement this_ptr_conv;
14147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14148         this_ptr_conv.is_owned = false;
14149         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
14150 }
14151
14152 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
14153         LDKUnsignedChannelAnnouncement this_ptr_conv;
14154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14155         this_ptr_conv.is_owned = false;
14156         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14157         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
14158         return ret_arr;
14159 }
14160
14161 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
14162         LDKUnsignedChannelAnnouncement this_ptr_conv;
14163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14164         this_ptr_conv.is_owned = false;
14165         LDKPublicKey val_ref;
14166         CHECK(*((uint32_t*)val) == 33);
14167         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14168         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
14169 }
14170
14171 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
14172         LDKUnsignedChannelAnnouncement this_ptr_conv;
14173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14174         this_ptr_conv.is_owned = false;
14175         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14176         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
14177         return ret_arr;
14178 }
14179
14180 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
14181         LDKUnsignedChannelAnnouncement this_ptr_conv;
14182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14183         this_ptr_conv.is_owned = false;
14184         LDKPublicKey val_ref;
14185         CHECK(*((uint32_t*)val) == 33);
14186         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14187         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
14188 }
14189
14190 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
14191         LDKUnsignedChannelAnnouncement this_ptr_conv;
14192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14193         this_ptr_conv.is_owned = false;
14194         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14195         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
14196         return ret_arr;
14197 }
14198
14199 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
14200         LDKUnsignedChannelAnnouncement this_ptr_conv;
14201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14202         this_ptr_conv.is_owned = false;
14203         LDKPublicKey val_ref;
14204         CHECK(*((uint32_t*)val) == 33);
14205         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14206         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
14207 }
14208
14209 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
14210         LDKUnsignedChannelAnnouncement this_ptr_conv;
14211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14212         this_ptr_conv.is_owned = false;
14213         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14214         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
14215         return ret_arr;
14216 }
14217
14218 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
14219         LDKUnsignedChannelAnnouncement this_ptr_conv;
14220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14221         this_ptr_conv.is_owned = false;
14222         LDKPublicKey val_ref;
14223         CHECK(*((uint32_t*)val) == 33);
14224         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14225         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
14226 }
14227
14228 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
14229         LDKUnsignedChannelAnnouncement orig_conv;
14230         orig_conv.inner = (void*)(orig & (~1));
14231         orig_conv.is_owned = false;
14232         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
14233         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14234         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14235         long ret_ref = (long)ret_var.inner;
14236         if (ret_var.is_owned) {
14237                 ret_ref |= 1;
14238         }
14239         return ret_ref;
14240 }
14241
14242 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
14243         LDKChannelAnnouncement this_obj_conv;
14244         this_obj_conv.inner = (void*)(this_obj & (~1));
14245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14246         ChannelAnnouncement_free(this_obj_conv);
14247 }
14248
14249 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
14250         LDKChannelAnnouncement this_ptr_conv;
14251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14252         this_ptr_conv.is_owned = false;
14253         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14254         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
14255         return ret_arr;
14256 }
14257
14258 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
14259         LDKChannelAnnouncement this_ptr_conv;
14260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14261         this_ptr_conv.is_owned = false;
14262         LDKSignature val_ref;
14263         CHECK(*((uint32_t*)val) == 64);
14264         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14265         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
14266 }
14267
14268 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
14269         LDKChannelAnnouncement this_ptr_conv;
14270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14271         this_ptr_conv.is_owned = false;
14272         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14273         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
14274         return ret_arr;
14275 }
14276
14277 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
14278         LDKChannelAnnouncement this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         LDKSignature val_ref;
14282         CHECK(*((uint32_t*)val) == 64);
14283         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14284         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
14285 }
14286
14287 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
14288         LDKChannelAnnouncement this_ptr_conv;
14289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14290         this_ptr_conv.is_owned = false;
14291         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14292         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
14293         return ret_arr;
14294 }
14295
14296 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
14297         LDKChannelAnnouncement this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         LDKSignature val_ref;
14301         CHECK(*((uint32_t*)val) == 64);
14302         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14303         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
14304 }
14305
14306 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
14307         LDKChannelAnnouncement this_ptr_conv;
14308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14309         this_ptr_conv.is_owned = false;
14310         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14311         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
14312         return ret_arr;
14313 }
14314
14315 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
14316         LDKChannelAnnouncement this_ptr_conv;
14317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14318         this_ptr_conv.is_owned = false;
14319         LDKSignature val_ref;
14320         CHECK(*((uint32_t*)val) == 64);
14321         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14322         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
14323 }
14324
14325 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
14326         LDKChannelAnnouncement this_ptr_conv;
14327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14328         this_ptr_conv.is_owned = false;
14329         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
14330         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14331         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14332         long ret_ref = (long)ret_var.inner;
14333         if (ret_var.is_owned) {
14334                 ret_ref |= 1;
14335         }
14336         return ret_ref;
14337 }
14338
14339 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
14340         LDKChannelAnnouncement this_ptr_conv;
14341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14342         this_ptr_conv.is_owned = false;
14343         LDKUnsignedChannelAnnouncement val_conv;
14344         val_conv.inner = (void*)(val & (~1));
14345         val_conv.is_owned = (val & 1) || (val == 0);
14346         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
14347         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
14348 }
14349
14350 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_new(int8_tArray node_signature_1_arg, int8_tArray node_signature_2_arg, int8_tArray bitcoin_signature_1_arg, int8_tArray bitcoin_signature_2_arg, uint32_t contents_arg) {
14351         LDKSignature node_signature_1_arg_ref;
14352         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
14353         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
14354         LDKSignature node_signature_2_arg_ref;
14355         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
14356         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
14357         LDKSignature bitcoin_signature_1_arg_ref;
14358         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
14359         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
14360         LDKSignature bitcoin_signature_2_arg_ref;
14361         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
14362         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
14363         LDKUnsignedChannelAnnouncement contents_arg_conv;
14364         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14365         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14366         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
14367         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);
14368         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14369         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14370         long ret_ref = (long)ret_var.inner;
14371         if (ret_var.is_owned) {
14372                 ret_ref |= 1;
14373         }
14374         return ret_ref;
14375 }
14376
14377 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
14378         LDKChannelAnnouncement orig_conv;
14379         orig_conv.inner = (void*)(orig & (~1));
14380         orig_conv.is_owned = false;
14381         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
14382         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14383         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14384         long ret_ref = (long)ret_var.inner;
14385         if (ret_var.is_owned) {
14386                 ret_ref |= 1;
14387         }
14388         return ret_ref;
14389 }
14390
14391 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
14392         LDKUnsignedChannelUpdate this_obj_conv;
14393         this_obj_conv.inner = (void*)(this_obj & (~1));
14394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14395         UnsignedChannelUpdate_free(this_obj_conv);
14396 }
14397
14398 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
14399         LDKUnsignedChannelUpdate this_ptr_conv;
14400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14401         this_ptr_conv.is_owned = false;
14402         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14403         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
14404         return ret_arr;
14405 }
14406
14407 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14408         LDKUnsignedChannelUpdate this_ptr_conv;
14409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14410         this_ptr_conv.is_owned = false;
14411         LDKThirtyTwoBytes val_ref;
14412         CHECK(*((uint32_t*)val) == 32);
14413         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14414         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
14415 }
14416
14417 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
14418         LDKUnsignedChannelUpdate this_ptr_conv;
14419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14420         this_ptr_conv.is_owned = false;
14421         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
14422         return ret_val;
14423 }
14424
14425 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14426         LDKUnsignedChannelUpdate this_ptr_conv;
14427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14428         this_ptr_conv.is_owned = false;
14429         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
14430 }
14431
14432 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
14433         LDKUnsignedChannelUpdate this_ptr_conv;
14434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14435         this_ptr_conv.is_owned = false;
14436         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
14437         return ret_val;
14438 }
14439
14440 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
14441         LDKUnsignedChannelUpdate this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
14445 }
14446
14447 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
14448         LDKUnsignedChannelUpdate this_ptr_conv;
14449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14450         this_ptr_conv.is_owned = false;
14451         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
14452         return ret_val;
14453 }
14454
14455 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
14456         LDKUnsignedChannelUpdate this_ptr_conv;
14457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14458         this_ptr_conv.is_owned = false;
14459         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
14460 }
14461
14462 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
14463         LDKUnsignedChannelUpdate this_ptr_conv;
14464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14465         this_ptr_conv.is_owned = false;
14466         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
14467         return ret_val;
14468 }
14469
14470 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14471         LDKUnsignedChannelUpdate this_ptr_conv;
14472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14473         this_ptr_conv.is_owned = false;
14474         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
14475 }
14476
14477 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
14478         LDKUnsignedChannelUpdate this_ptr_conv;
14479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14480         this_ptr_conv.is_owned = false;
14481         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
14482         return ret_val;
14483 }
14484
14485 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14486         LDKUnsignedChannelUpdate this_ptr_conv;
14487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14488         this_ptr_conv.is_owned = false;
14489         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
14490 }
14491
14492 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
14493         LDKUnsignedChannelUpdate this_ptr_conv;
14494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14495         this_ptr_conv.is_owned = false;
14496         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
14497         return ret_val;
14498 }
14499
14500 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
14501         LDKUnsignedChannelUpdate this_ptr_conv;
14502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14503         this_ptr_conv.is_owned = false;
14504         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
14505 }
14506
14507 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
14508         LDKUnsignedChannelUpdate this_ptr_conv;
14509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14510         this_ptr_conv.is_owned = false;
14511         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
14512         return ret_val;
14513 }
14514
14515 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14516         LDKUnsignedChannelUpdate this_ptr_conv;
14517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14518         this_ptr_conv.is_owned = false;
14519         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
14520 }
14521
14522 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
14523         LDKUnsignedChannelUpdate orig_conv;
14524         orig_conv.inner = (void*)(orig & (~1));
14525         orig_conv.is_owned = false;
14526         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
14527         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14528         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14529         long ret_ref = (long)ret_var.inner;
14530         if (ret_var.is_owned) {
14531                 ret_ref |= 1;
14532         }
14533         return ret_ref;
14534 }
14535
14536 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
14537         LDKChannelUpdate this_obj_conv;
14538         this_obj_conv.inner = (void*)(this_obj & (~1));
14539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14540         ChannelUpdate_free(this_obj_conv);
14541 }
14542
14543 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
14544         LDKChannelUpdate this_ptr_conv;
14545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14546         this_ptr_conv.is_owned = false;
14547         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14548         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
14549         return ret_arr;
14550 }
14551
14552 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
14553         LDKChannelUpdate this_ptr_conv;
14554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14555         this_ptr_conv.is_owned = false;
14556         LDKSignature val_ref;
14557         CHECK(*((uint32_t*)val) == 64);
14558         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14559         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
14560 }
14561
14562 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
14563         LDKChannelUpdate this_ptr_conv;
14564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14565         this_ptr_conv.is_owned = false;
14566         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
14567         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14568         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14569         long ret_ref = (long)ret_var.inner;
14570         if (ret_var.is_owned) {
14571                 ret_ref |= 1;
14572         }
14573         return ret_ref;
14574 }
14575
14576 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
14577         LDKChannelUpdate this_ptr_conv;
14578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14579         this_ptr_conv.is_owned = false;
14580         LDKUnsignedChannelUpdate val_conv;
14581         val_conv.inner = (void*)(val & (~1));
14582         val_conv.is_owned = (val & 1) || (val == 0);
14583         val_conv = UnsignedChannelUpdate_clone(&val_conv);
14584         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
14585 }
14586
14587 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
14588         LDKSignature signature_arg_ref;
14589         CHECK(*((uint32_t*)signature_arg) == 64);
14590         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14591         LDKUnsignedChannelUpdate contents_arg_conv;
14592         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14593         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14594         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
14595         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
14596         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14597         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14598         long ret_ref = (long)ret_var.inner;
14599         if (ret_var.is_owned) {
14600                 ret_ref |= 1;
14601         }
14602         return ret_ref;
14603 }
14604
14605 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
14606         LDKChannelUpdate orig_conv;
14607         orig_conv.inner = (void*)(orig & (~1));
14608         orig_conv.is_owned = false;
14609         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
14610         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14611         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14612         long ret_ref = (long)ret_var.inner;
14613         if (ret_var.is_owned) {
14614                 ret_ref |= 1;
14615         }
14616         return ret_ref;
14617 }
14618
14619 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
14620         LDKQueryChannelRange this_obj_conv;
14621         this_obj_conv.inner = (void*)(this_obj & (~1));
14622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14623         QueryChannelRange_free(this_obj_conv);
14624 }
14625
14626 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
14627         LDKQueryChannelRange this_ptr_conv;
14628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14629         this_ptr_conv.is_owned = false;
14630         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14631         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
14632         return ret_arr;
14633 }
14634
14635 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14636         LDKQueryChannelRange this_ptr_conv;
14637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14638         this_ptr_conv.is_owned = false;
14639         LDKThirtyTwoBytes val_ref;
14640         CHECK(*((uint32_t*)val) == 32);
14641         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14642         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14643 }
14644
14645 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
14646         LDKQueryChannelRange this_ptr_conv;
14647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14648         this_ptr_conv.is_owned = false;
14649         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
14650         return ret_val;
14651 }
14652
14653 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14654         LDKQueryChannelRange this_ptr_conv;
14655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14656         this_ptr_conv.is_owned = false;
14657         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
14658 }
14659
14660 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14661         LDKQueryChannelRange this_ptr_conv;
14662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14663         this_ptr_conv.is_owned = false;
14664         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
14665         return ret_val;
14666 }
14667
14668 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14669         LDKQueryChannelRange this_ptr_conv;
14670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14671         this_ptr_conv.is_owned = false;
14672         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14673 }
14674
14675 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
14676         LDKThirtyTwoBytes chain_hash_arg_ref;
14677         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14678         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14679         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
14680         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14681         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14682         long ret_ref = (long)ret_var.inner;
14683         if (ret_var.is_owned) {
14684                 ret_ref |= 1;
14685         }
14686         return ret_ref;
14687 }
14688
14689 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
14690         LDKQueryChannelRange orig_conv;
14691         orig_conv.inner = (void*)(orig & (~1));
14692         orig_conv.is_owned = false;
14693         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
14694         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14695         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14696         long ret_ref = (long)ret_var.inner;
14697         if (ret_var.is_owned) {
14698                 ret_ref |= 1;
14699         }
14700         return ret_ref;
14701 }
14702
14703 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
14704         LDKReplyChannelRange this_obj_conv;
14705         this_obj_conv.inner = (void*)(this_obj & (~1));
14706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14707         ReplyChannelRange_free(this_obj_conv);
14708 }
14709
14710 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
14711         LDKReplyChannelRange this_ptr_conv;
14712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14713         this_ptr_conv.is_owned = false;
14714         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14715         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
14716         return ret_arr;
14717 }
14718
14719 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14720         LDKReplyChannelRange this_ptr_conv;
14721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14722         this_ptr_conv.is_owned = false;
14723         LDKThirtyTwoBytes val_ref;
14724         CHECK(*((uint32_t*)val) == 32);
14725         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14726         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14727 }
14728
14729 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
14730         LDKReplyChannelRange this_ptr_conv;
14731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14732         this_ptr_conv.is_owned = false;
14733         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
14734         return ret_val;
14735 }
14736
14737 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14738         LDKReplyChannelRange this_ptr_conv;
14739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14740         this_ptr_conv.is_owned = false;
14741         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
14742 }
14743
14744 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14745         LDKReplyChannelRange this_ptr_conv;
14746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14747         this_ptr_conv.is_owned = false;
14748         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
14749         return ret_val;
14750 }
14751
14752 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14753         LDKReplyChannelRange this_ptr_conv;
14754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14755         this_ptr_conv.is_owned = false;
14756         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14757 }
14758
14759 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
14760         LDKReplyChannelRange this_ptr_conv;
14761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14762         this_ptr_conv.is_owned = false;
14763         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
14764         return ret_val;
14765 }
14766
14767 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
14768         LDKReplyChannelRange this_ptr_conv;
14769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14770         this_ptr_conv.is_owned = false;
14771         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
14772 }
14773
14774 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14775         LDKReplyChannelRange this_ptr_conv;
14776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14777         this_ptr_conv.is_owned = false;
14778         LDKCVec_u64Z val_constr;
14779         val_constr.datalen = *((uint32_t*)val);
14780         if (val_constr.datalen > 0)
14781                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14782         else
14783                 val_constr.data = NULL;
14784         int64_t* val_vals = (int64_t*)(val + 4);
14785         for (size_t i = 0; i < val_constr.datalen; i++) {
14786                 int64_t val_conv_8 = val_vals[i];
14787                 val_constr.data[i] = val_conv_8;
14788         }
14789         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
14790 }
14791
14792 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_new(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) {
14793         LDKThirtyTwoBytes chain_hash_arg_ref;
14794         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14795         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14796         LDKCVec_u64Z short_channel_ids_arg_constr;
14797         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14798         if (short_channel_ids_arg_constr.datalen > 0)
14799                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14800         else
14801                 short_channel_ids_arg_constr.data = NULL;
14802         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14803         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14804                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14805                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14806         }
14807         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
14808         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14809         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14810         long ret_ref = (long)ret_var.inner;
14811         if (ret_var.is_owned) {
14812                 ret_ref |= 1;
14813         }
14814         return ret_ref;
14815 }
14816
14817 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
14818         LDKReplyChannelRange orig_conv;
14819         orig_conv.inner = (void*)(orig & (~1));
14820         orig_conv.is_owned = false;
14821         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
14822         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14823         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14824         long ret_ref = (long)ret_var.inner;
14825         if (ret_var.is_owned) {
14826                 ret_ref |= 1;
14827         }
14828         return ret_ref;
14829 }
14830
14831 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
14832         LDKQueryShortChannelIds this_obj_conv;
14833         this_obj_conv.inner = (void*)(this_obj & (~1));
14834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14835         QueryShortChannelIds_free(this_obj_conv);
14836 }
14837
14838 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
14839         LDKQueryShortChannelIds this_ptr_conv;
14840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14841         this_ptr_conv.is_owned = false;
14842         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14843         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
14844         return ret_arr;
14845 }
14846
14847 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14848         LDKQueryShortChannelIds this_ptr_conv;
14849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14850         this_ptr_conv.is_owned = false;
14851         LDKThirtyTwoBytes val_ref;
14852         CHECK(*((uint32_t*)val) == 32);
14853         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14854         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
14855 }
14856
14857 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14858         LDKQueryShortChannelIds this_ptr_conv;
14859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14860         this_ptr_conv.is_owned = false;
14861         LDKCVec_u64Z val_constr;
14862         val_constr.datalen = *((uint32_t*)val);
14863         if (val_constr.datalen > 0)
14864                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14865         else
14866                 val_constr.data = NULL;
14867         int64_t* val_vals = (int64_t*)(val + 4);
14868         for (size_t i = 0; i < val_constr.datalen; i++) {
14869                 int64_t val_conv_8 = val_vals[i];
14870                 val_constr.data[i] = val_conv_8;
14871         }
14872         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
14873 }
14874
14875 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
14876         LDKThirtyTwoBytes chain_hash_arg_ref;
14877         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14878         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14879         LDKCVec_u64Z short_channel_ids_arg_constr;
14880         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14881         if (short_channel_ids_arg_constr.datalen > 0)
14882                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14883         else
14884                 short_channel_ids_arg_constr.data = NULL;
14885         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14886         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14887                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14888                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14889         }
14890         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
14891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14893         long ret_ref = (long)ret_var.inner;
14894         if (ret_var.is_owned) {
14895                 ret_ref |= 1;
14896         }
14897         return ret_ref;
14898 }
14899
14900 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
14901         LDKQueryShortChannelIds orig_conv;
14902         orig_conv.inner = (void*)(orig & (~1));
14903         orig_conv.is_owned = false;
14904         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
14905         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14906         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14907         long ret_ref = (long)ret_var.inner;
14908         if (ret_var.is_owned) {
14909                 ret_ref |= 1;
14910         }
14911         return ret_ref;
14912 }
14913
14914 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
14915         LDKReplyShortChannelIdsEnd this_obj_conv;
14916         this_obj_conv.inner = (void*)(this_obj & (~1));
14917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14918         ReplyShortChannelIdsEnd_free(this_obj_conv);
14919 }
14920
14921 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
14922         LDKReplyShortChannelIdsEnd this_ptr_conv;
14923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14924         this_ptr_conv.is_owned = false;
14925         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14926         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
14927         return ret_arr;
14928 }
14929
14930 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14931         LDKReplyShortChannelIdsEnd this_ptr_conv;
14932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14933         this_ptr_conv.is_owned = false;
14934         LDKThirtyTwoBytes val_ref;
14935         CHECK(*((uint32_t*)val) == 32);
14936         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14937         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
14938 }
14939
14940 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
14941         LDKReplyShortChannelIdsEnd this_ptr_conv;
14942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14943         this_ptr_conv.is_owned = false;
14944         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
14945         return ret_val;
14946 }
14947
14948 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
14949         LDKReplyShortChannelIdsEnd this_ptr_conv;
14950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14951         this_ptr_conv.is_owned = false;
14952         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
14953 }
14954
14955 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
14956         LDKThirtyTwoBytes chain_hash_arg_ref;
14957         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14958         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14959         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
14960         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14961         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14962         long ret_ref = (long)ret_var.inner;
14963         if (ret_var.is_owned) {
14964                 ret_ref |= 1;
14965         }
14966         return ret_ref;
14967 }
14968
14969 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
14970         LDKReplyShortChannelIdsEnd orig_conv;
14971         orig_conv.inner = (void*)(orig & (~1));
14972         orig_conv.is_owned = false;
14973         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
14974         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14975         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14976         long ret_ref = (long)ret_var.inner;
14977         if (ret_var.is_owned) {
14978                 ret_ref |= 1;
14979         }
14980         return ret_ref;
14981 }
14982
14983 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
14984         LDKGossipTimestampFilter this_obj_conv;
14985         this_obj_conv.inner = (void*)(this_obj & (~1));
14986         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14987         GossipTimestampFilter_free(this_obj_conv);
14988 }
14989
14990 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
14991         LDKGossipTimestampFilter this_ptr_conv;
14992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14993         this_ptr_conv.is_owned = false;
14994         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14995         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
14996         return ret_arr;
14997 }
14998
14999 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15000         LDKGossipTimestampFilter this_ptr_conv;
15001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15002         this_ptr_conv.is_owned = false;
15003         LDKThirtyTwoBytes val_ref;
15004         CHECK(*((uint32_t*)val) == 32);
15005         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15006         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
15007 }
15008
15009 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
15010         LDKGossipTimestampFilter this_ptr_conv;
15011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15012         this_ptr_conv.is_owned = false;
15013         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
15014         return ret_val;
15015 }
15016
15017 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
15018         LDKGossipTimestampFilter this_ptr_conv;
15019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15020         this_ptr_conv.is_owned = false;
15021         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
15022 }
15023
15024 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
15025         LDKGossipTimestampFilter this_ptr_conv;
15026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15027         this_ptr_conv.is_owned = false;
15028         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
15029         return ret_val;
15030 }
15031
15032 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
15033         LDKGossipTimestampFilter this_ptr_conv;
15034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15035         this_ptr_conv.is_owned = false;
15036         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
15037 }
15038
15039 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
15040         LDKThirtyTwoBytes chain_hash_arg_ref;
15041         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15042         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15043         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
15044         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15045         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15046         long ret_ref = (long)ret_var.inner;
15047         if (ret_var.is_owned) {
15048                 ret_ref |= 1;
15049         }
15050         return ret_ref;
15051 }
15052
15053 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
15054         LDKGossipTimestampFilter orig_conv;
15055         orig_conv.inner = (void*)(orig & (~1));
15056         orig_conv.is_owned = false;
15057         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
15058         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15059         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15060         long ret_ref = (long)ret_var.inner;
15061         if (ret_var.is_owned) {
15062                 ret_ref |= 1;
15063         }
15064         return ret_ref;
15065 }
15066
15067 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
15068         if ((this_ptr & 1) != 0) return;
15069         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
15070         FREE((void*)this_ptr);
15071         ErrorAction_free(this_ptr_conv);
15072 }
15073
15074 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
15075         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
15076         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15077         *ret_copy = ErrorAction_clone(orig_conv);
15078         long ret_ref = (long)ret_copy;
15079         return ret_ref;
15080 }
15081
15082 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
15083         LDKLightningError this_obj_conv;
15084         this_obj_conv.inner = (void*)(this_obj & (~1));
15085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15086         LightningError_free(this_obj_conv);
15087 }
15088
15089 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
15090         LDKLightningError this_ptr_conv;
15091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15092         this_ptr_conv.is_owned = false;
15093         LDKStr _str = LightningError_get_err(&this_ptr_conv);
15094         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
15095         return _conv;
15096 }
15097
15098 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
15099         LDKLightningError this_ptr_conv;
15100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15101         this_ptr_conv.is_owned = false;
15102         LDKCVec_u8Z val_ref;
15103         val_ref.datalen = *((uint32_t*)val);
15104         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15105         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
15106         LightningError_set_err(&this_ptr_conv, val_ref);
15107 }
15108
15109 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
15110         LDKLightningError this_ptr_conv;
15111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15112         this_ptr_conv.is_owned = false;
15113         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15114         *ret_copy = LightningError_get_action(&this_ptr_conv);
15115         long ret_ref = (long)ret_copy;
15116         return ret_ref;
15117 }
15118
15119 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
15120         LDKLightningError this_ptr_conv;
15121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15122         this_ptr_conv.is_owned = false;
15123         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
15124         FREE((void*)val);
15125         LightningError_set_action(&this_ptr_conv, val_conv);
15126 }
15127
15128 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
15129         LDKCVec_u8Z err_arg_ref;
15130         err_arg_ref.datalen = *((uint32_t*)err_arg);
15131         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15132         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
15133         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
15134         FREE((void*)action_arg);
15135         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
15136         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15137         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15138         long ret_ref = (long)ret_var.inner;
15139         if (ret_var.is_owned) {
15140                 ret_ref |= 1;
15141         }
15142         return ret_ref;
15143 }
15144
15145 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
15146         LDKLightningError orig_conv;
15147         orig_conv.inner = (void*)(orig & (~1));
15148         orig_conv.is_owned = false;
15149         LDKLightningError ret_var = LightningError_clone(&orig_conv);
15150         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15151         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15152         long ret_ref = (long)ret_var.inner;
15153         if (ret_var.is_owned) {
15154                 ret_ref |= 1;
15155         }
15156         return ret_ref;
15157 }
15158
15159 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
15160         LDKCommitmentUpdate this_obj_conv;
15161         this_obj_conv.inner = (void*)(this_obj & (~1));
15162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15163         CommitmentUpdate_free(this_obj_conv);
15164 }
15165
15166 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
15167         LDKCommitmentUpdate this_ptr_conv;
15168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15169         this_ptr_conv.is_owned = false;
15170         LDKCVec_UpdateAddHTLCZ val_constr;
15171         val_constr.datalen = *((uint32_t*)val);
15172         if (val_constr.datalen > 0)
15173                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15174         else
15175                 val_constr.data = NULL;
15176         uint32_t* val_vals = (uint32_t*)(val + 4);
15177         for (size_t p = 0; p < val_constr.datalen; p++) {
15178                 uint32_t val_conv_15 = val_vals[p];
15179                 LDKUpdateAddHTLC val_conv_15_conv;
15180                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
15181                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
15182                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
15183                 val_constr.data[p] = val_conv_15_conv;
15184         }
15185         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
15186 }
15187
15188 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
15189         LDKCommitmentUpdate this_ptr_conv;
15190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15191         this_ptr_conv.is_owned = false;
15192         LDKCVec_UpdateFulfillHTLCZ val_constr;
15193         val_constr.datalen = *((uint32_t*)val);
15194         if (val_constr.datalen > 0)
15195                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15196         else
15197                 val_constr.data = NULL;
15198         uint32_t* val_vals = (uint32_t*)(val + 4);
15199         for (size_t t = 0; t < val_constr.datalen; t++) {
15200                 uint32_t val_conv_19 = val_vals[t];
15201                 LDKUpdateFulfillHTLC val_conv_19_conv;
15202                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
15203                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
15204                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
15205                 val_constr.data[t] = val_conv_19_conv;
15206         }
15207         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
15208 }
15209
15210 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
15211         LDKCommitmentUpdate this_ptr_conv;
15212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15213         this_ptr_conv.is_owned = false;
15214         LDKCVec_UpdateFailHTLCZ val_constr;
15215         val_constr.datalen = *((uint32_t*)val);
15216         if (val_constr.datalen > 0)
15217                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15218         else
15219                 val_constr.data = NULL;
15220         uint32_t* val_vals = (uint32_t*)(val + 4);
15221         for (size_t q = 0; q < val_constr.datalen; q++) {
15222                 uint32_t val_conv_16 = val_vals[q];
15223                 LDKUpdateFailHTLC val_conv_16_conv;
15224                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
15225                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
15226                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
15227                 val_constr.data[q] = val_conv_16_conv;
15228         }
15229         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
15230 }
15231
15232 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
15233         LDKCommitmentUpdate this_ptr_conv;
15234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15235         this_ptr_conv.is_owned = false;
15236         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
15237         val_constr.datalen = *((uint32_t*)val);
15238         if (val_constr.datalen > 0)
15239                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15240         else
15241                 val_constr.data = NULL;
15242         uint32_t* val_vals = (uint32_t*)(val + 4);
15243         for (size_t z = 0; z < val_constr.datalen; z++) {
15244                 uint32_t val_conv_25 = val_vals[z];
15245                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
15246                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
15247                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
15248                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
15249                 val_constr.data[z] = val_conv_25_conv;
15250         }
15251         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
15252 }
15253
15254 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
15255         LDKCommitmentUpdate this_ptr_conv;
15256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15257         this_ptr_conv.is_owned = false;
15258         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
15259         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15260         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15261         long ret_ref = (long)ret_var.inner;
15262         if (ret_var.is_owned) {
15263                 ret_ref |= 1;
15264         }
15265         return ret_ref;
15266 }
15267
15268 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
15269         LDKCommitmentUpdate this_ptr_conv;
15270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15271         this_ptr_conv.is_owned = false;
15272         LDKUpdateFee val_conv;
15273         val_conv.inner = (void*)(val & (~1));
15274         val_conv.is_owned = (val & 1) || (val == 0);
15275         val_conv = UpdateFee_clone(&val_conv);
15276         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
15277 }
15278
15279 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
15280         LDKCommitmentUpdate this_ptr_conv;
15281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15282         this_ptr_conv.is_owned = false;
15283         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
15284         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15285         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15286         long ret_ref = (long)ret_var.inner;
15287         if (ret_var.is_owned) {
15288                 ret_ref |= 1;
15289         }
15290         return ret_ref;
15291 }
15292
15293 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
15294         LDKCommitmentUpdate this_ptr_conv;
15295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15296         this_ptr_conv.is_owned = false;
15297         LDKCommitmentSigned val_conv;
15298         val_conv.inner = (void*)(val & (~1));
15299         val_conv.is_owned = (val & 1) || (val == 0);
15300         val_conv = CommitmentSigned_clone(&val_conv);
15301         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
15302 }
15303
15304 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_new(uint32_tArray update_add_htlcs_arg, uint32_tArray update_fulfill_htlcs_arg, uint32_tArray update_fail_htlcs_arg, uint32_tArray update_fail_malformed_htlcs_arg, uint32_t update_fee_arg, uint32_t commitment_signed_arg) {
15305         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
15306         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
15307         if (update_add_htlcs_arg_constr.datalen > 0)
15308                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15309         else
15310                 update_add_htlcs_arg_constr.data = NULL;
15311         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
15312         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
15313                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
15314                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
15315                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
15316                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
15317                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
15318                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
15319         }
15320         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
15321         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
15322         if (update_fulfill_htlcs_arg_constr.datalen > 0)
15323                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15324         else
15325                 update_fulfill_htlcs_arg_constr.data = NULL;
15326         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
15327         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
15328                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
15329                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
15330                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
15331                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
15332                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
15333                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
15334         }
15335         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
15336         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
15337         if (update_fail_htlcs_arg_constr.datalen > 0)
15338                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15339         else
15340                 update_fail_htlcs_arg_constr.data = NULL;
15341         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
15342         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
15343                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
15344                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
15345                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
15346                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
15347                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
15348                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
15349         }
15350         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
15351         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
15352         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
15353                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15354         else
15355                 update_fail_malformed_htlcs_arg_constr.data = NULL;
15356         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
15357         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
15358                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
15359                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
15360                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
15361                 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);
15362                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
15363                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
15364         }
15365         LDKUpdateFee update_fee_arg_conv;
15366         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
15367         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
15368         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
15369         LDKCommitmentSigned commitment_signed_arg_conv;
15370         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
15371         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
15372         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
15373         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);
15374         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15375         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15376         long ret_ref = (long)ret_var.inner;
15377         if (ret_var.is_owned) {
15378                 ret_ref |= 1;
15379         }
15380         return ret_ref;
15381 }
15382
15383 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
15384         LDKCommitmentUpdate orig_conv;
15385         orig_conv.inner = (void*)(orig & (~1));
15386         orig_conv.is_owned = false;
15387         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
15388         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15389         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15390         long ret_ref = (long)ret_var.inner;
15391         if (ret_var.is_owned) {
15392                 ret_ref |= 1;
15393         }
15394         return ret_ref;
15395 }
15396
15397 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
15398         if ((this_ptr & 1) != 0) return;
15399         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
15400         FREE((void*)this_ptr);
15401         HTLCFailChannelUpdate_free(this_ptr_conv);
15402 }
15403
15404 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
15405         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
15406         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
15407         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
15408         long ret_ref = (long)ret_copy;
15409         return ret_ref;
15410 }
15411
15412 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
15413         if ((this_ptr & 1) != 0) return;
15414         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
15415         FREE((void*)this_ptr);
15416         ChannelMessageHandler_free(this_ptr_conv);
15417 }
15418
15419 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
15420         if ((this_ptr & 1) != 0) return;
15421         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
15422         FREE((void*)this_ptr);
15423         RoutingMessageHandler_free(this_ptr_conv);
15424 }
15425
15426 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
15427         LDKAcceptChannel obj_conv;
15428         obj_conv.inner = (void*)(obj & (~1));
15429         obj_conv.is_owned = false;
15430         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
15431         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15432         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15433         CVec_u8Z_free(ret_var);
15434         return ret_arr;
15435 }
15436
15437 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
15438         LDKu8slice ser_ref;
15439         ser_ref.datalen = *((uint32_t*)ser);
15440         ser_ref.data = (int8_t*)(ser + 4);
15441         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15442         *ret_conv = AcceptChannel_read(ser_ref);
15443         return (long)ret_conv;
15444 }
15445
15446 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
15447         LDKAnnouncementSignatures obj_conv;
15448         obj_conv.inner = (void*)(obj & (~1));
15449         obj_conv.is_owned = false;
15450         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
15451         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15452         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15453         CVec_u8Z_free(ret_var);
15454         return ret_arr;
15455 }
15456
15457 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
15458         LDKu8slice ser_ref;
15459         ser_ref.datalen = *((uint32_t*)ser);
15460         ser_ref.data = (int8_t*)(ser + 4);
15461         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15462         *ret_conv = AnnouncementSignatures_read(ser_ref);
15463         return (long)ret_conv;
15464 }
15465
15466 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
15467         LDKChannelReestablish obj_conv;
15468         obj_conv.inner = (void*)(obj & (~1));
15469         obj_conv.is_owned = false;
15470         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
15471         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15472         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15473         CVec_u8Z_free(ret_var);
15474         return ret_arr;
15475 }
15476
15477 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
15478         LDKu8slice ser_ref;
15479         ser_ref.datalen = *((uint32_t*)ser);
15480         ser_ref.data = (int8_t*)(ser + 4);
15481         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15482         *ret_conv = ChannelReestablish_read(ser_ref);
15483         return (long)ret_conv;
15484 }
15485
15486 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
15487         LDKClosingSigned obj_conv;
15488         obj_conv.inner = (void*)(obj & (~1));
15489         obj_conv.is_owned = false;
15490         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
15491         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15492         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15493         CVec_u8Z_free(ret_var);
15494         return ret_arr;
15495 }
15496
15497 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
15498         LDKu8slice ser_ref;
15499         ser_ref.datalen = *((uint32_t*)ser);
15500         ser_ref.data = (int8_t*)(ser + 4);
15501         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15502         *ret_conv = ClosingSigned_read(ser_ref);
15503         return (long)ret_conv;
15504 }
15505
15506 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
15507         LDKCommitmentSigned obj_conv;
15508         obj_conv.inner = (void*)(obj & (~1));
15509         obj_conv.is_owned = false;
15510         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
15511         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15512         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15513         CVec_u8Z_free(ret_var);
15514         return ret_arr;
15515 }
15516
15517 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
15518         LDKu8slice ser_ref;
15519         ser_ref.datalen = *((uint32_t*)ser);
15520         ser_ref.data = (int8_t*)(ser + 4);
15521         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15522         *ret_conv = CommitmentSigned_read(ser_ref);
15523         return (long)ret_conv;
15524 }
15525
15526 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
15527         LDKFundingCreated obj_conv;
15528         obj_conv.inner = (void*)(obj & (~1));
15529         obj_conv.is_owned = false;
15530         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
15531         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15532         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15533         CVec_u8Z_free(ret_var);
15534         return ret_arr;
15535 }
15536
15537 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
15538         LDKu8slice ser_ref;
15539         ser_ref.datalen = *((uint32_t*)ser);
15540         ser_ref.data = (int8_t*)(ser + 4);
15541         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15542         *ret_conv = FundingCreated_read(ser_ref);
15543         return (long)ret_conv;
15544 }
15545
15546 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
15547         LDKFundingSigned obj_conv;
15548         obj_conv.inner = (void*)(obj & (~1));
15549         obj_conv.is_owned = false;
15550         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
15551         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15552         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15553         CVec_u8Z_free(ret_var);
15554         return ret_arr;
15555 }
15556
15557 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
15558         LDKu8slice ser_ref;
15559         ser_ref.datalen = *((uint32_t*)ser);
15560         ser_ref.data = (int8_t*)(ser + 4);
15561         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15562         *ret_conv = FundingSigned_read(ser_ref);
15563         return (long)ret_conv;
15564 }
15565
15566 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
15567         LDKFundingLocked obj_conv;
15568         obj_conv.inner = (void*)(obj & (~1));
15569         obj_conv.is_owned = false;
15570         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
15571         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15572         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15573         CVec_u8Z_free(ret_var);
15574         return ret_arr;
15575 }
15576
15577 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
15578         LDKu8slice ser_ref;
15579         ser_ref.datalen = *((uint32_t*)ser);
15580         ser_ref.data = (int8_t*)(ser + 4);
15581         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15582         *ret_conv = FundingLocked_read(ser_ref);
15583         return (long)ret_conv;
15584 }
15585
15586 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
15587         LDKInit obj_conv;
15588         obj_conv.inner = (void*)(obj & (~1));
15589         obj_conv.is_owned = false;
15590         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
15591         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15592         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15593         CVec_u8Z_free(ret_var);
15594         return ret_arr;
15595 }
15596
15597 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
15598         LDKu8slice ser_ref;
15599         ser_ref.datalen = *((uint32_t*)ser);
15600         ser_ref.data = (int8_t*)(ser + 4);
15601         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15602         *ret_conv = Init_read(ser_ref);
15603         return (long)ret_conv;
15604 }
15605
15606 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
15607         LDKOpenChannel obj_conv;
15608         obj_conv.inner = (void*)(obj & (~1));
15609         obj_conv.is_owned = false;
15610         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
15611         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15612         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15613         CVec_u8Z_free(ret_var);
15614         return ret_arr;
15615 }
15616
15617 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
15618         LDKu8slice ser_ref;
15619         ser_ref.datalen = *((uint32_t*)ser);
15620         ser_ref.data = (int8_t*)(ser + 4);
15621         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15622         *ret_conv = OpenChannel_read(ser_ref);
15623         return (long)ret_conv;
15624 }
15625
15626 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
15627         LDKRevokeAndACK obj_conv;
15628         obj_conv.inner = (void*)(obj & (~1));
15629         obj_conv.is_owned = false;
15630         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
15631         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15632         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15633         CVec_u8Z_free(ret_var);
15634         return ret_arr;
15635 }
15636
15637 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
15638         LDKu8slice ser_ref;
15639         ser_ref.datalen = *((uint32_t*)ser);
15640         ser_ref.data = (int8_t*)(ser + 4);
15641         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15642         *ret_conv = RevokeAndACK_read(ser_ref);
15643         return (long)ret_conv;
15644 }
15645
15646 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
15647         LDKShutdown obj_conv;
15648         obj_conv.inner = (void*)(obj & (~1));
15649         obj_conv.is_owned = false;
15650         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
15651         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15652         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15653         CVec_u8Z_free(ret_var);
15654         return ret_arr;
15655 }
15656
15657 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
15658         LDKu8slice ser_ref;
15659         ser_ref.datalen = *((uint32_t*)ser);
15660         ser_ref.data = (int8_t*)(ser + 4);
15661         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15662         *ret_conv = Shutdown_read(ser_ref);
15663         return (long)ret_conv;
15664 }
15665
15666 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
15667         LDKUpdateFailHTLC obj_conv;
15668         obj_conv.inner = (void*)(obj & (~1));
15669         obj_conv.is_owned = false;
15670         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
15671         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15672         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15673         CVec_u8Z_free(ret_var);
15674         return ret_arr;
15675 }
15676
15677 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
15678         LDKu8slice ser_ref;
15679         ser_ref.datalen = *((uint32_t*)ser);
15680         ser_ref.data = (int8_t*)(ser + 4);
15681         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15682         *ret_conv = UpdateFailHTLC_read(ser_ref);
15683         return (long)ret_conv;
15684 }
15685
15686 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
15687         LDKUpdateFailMalformedHTLC obj_conv;
15688         obj_conv.inner = (void*)(obj & (~1));
15689         obj_conv.is_owned = false;
15690         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
15691         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15692         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15693         CVec_u8Z_free(ret_var);
15694         return ret_arr;
15695 }
15696
15697 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
15698         LDKu8slice ser_ref;
15699         ser_ref.datalen = *((uint32_t*)ser);
15700         ser_ref.data = (int8_t*)(ser + 4);
15701         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15702         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
15703         return (long)ret_conv;
15704 }
15705
15706 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
15707         LDKUpdateFee obj_conv;
15708         obj_conv.inner = (void*)(obj & (~1));
15709         obj_conv.is_owned = false;
15710         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
15711         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15712         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15713         CVec_u8Z_free(ret_var);
15714         return ret_arr;
15715 }
15716
15717 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
15718         LDKu8slice ser_ref;
15719         ser_ref.datalen = *((uint32_t*)ser);
15720         ser_ref.data = (int8_t*)(ser + 4);
15721         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15722         *ret_conv = UpdateFee_read(ser_ref);
15723         return (long)ret_conv;
15724 }
15725
15726 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
15727         LDKUpdateFulfillHTLC obj_conv;
15728         obj_conv.inner = (void*)(obj & (~1));
15729         obj_conv.is_owned = false;
15730         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
15731         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15732         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15733         CVec_u8Z_free(ret_var);
15734         return ret_arr;
15735 }
15736
15737 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
15738         LDKu8slice ser_ref;
15739         ser_ref.datalen = *((uint32_t*)ser);
15740         ser_ref.data = (int8_t*)(ser + 4);
15741         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15742         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
15743         return (long)ret_conv;
15744 }
15745
15746 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
15747         LDKUpdateAddHTLC obj_conv;
15748         obj_conv.inner = (void*)(obj & (~1));
15749         obj_conv.is_owned = false;
15750         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
15751         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15752         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15753         CVec_u8Z_free(ret_var);
15754         return ret_arr;
15755 }
15756
15757 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
15758         LDKu8slice ser_ref;
15759         ser_ref.datalen = *((uint32_t*)ser);
15760         ser_ref.data = (int8_t*)(ser + 4);
15761         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15762         *ret_conv = UpdateAddHTLC_read(ser_ref);
15763         return (long)ret_conv;
15764 }
15765
15766 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
15767         LDKPing obj_conv;
15768         obj_conv.inner = (void*)(obj & (~1));
15769         obj_conv.is_owned = false;
15770         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
15771         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15772         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15773         CVec_u8Z_free(ret_var);
15774         return ret_arr;
15775 }
15776
15777 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
15778         LDKu8slice ser_ref;
15779         ser_ref.datalen = *((uint32_t*)ser);
15780         ser_ref.data = (int8_t*)(ser + 4);
15781         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15782         *ret_conv = Ping_read(ser_ref);
15783         return (long)ret_conv;
15784 }
15785
15786 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
15787         LDKPong obj_conv;
15788         obj_conv.inner = (void*)(obj & (~1));
15789         obj_conv.is_owned = false;
15790         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
15791         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15792         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15793         CVec_u8Z_free(ret_var);
15794         return ret_arr;
15795 }
15796
15797 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
15798         LDKu8slice ser_ref;
15799         ser_ref.datalen = *((uint32_t*)ser);
15800         ser_ref.data = (int8_t*)(ser + 4);
15801         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15802         *ret_conv = Pong_read(ser_ref);
15803         return (long)ret_conv;
15804 }
15805
15806 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
15807         LDKUnsignedChannelAnnouncement obj_conv;
15808         obj_conv.inner = (void*)(obj & (~1));
15809         obj_conv.is_owned = false;
15810         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
15811         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15812         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15813         CVec_u8Z_free(ret_var);
15814         return ret_arr;
15815 }
15816
15817 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
15818         LDKu8slice ser_ref;
15819         ser_ref.datalen = *((uint32_t*)ser);
15820         ser_ref.data = (int8_t*)(ser + 4);
15821         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15822         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
15823         return (long)ret_conv;
15824 }
15825
15826 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
15827         LDKChannelAnnouncement obj_conv;
15828         obj_conv.inner = (void*)(obj & (~1));
15829         obj_conv.is_owned = false;
15830         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
15831         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15832         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15833         CVec_u8Z_free(ret_var);
15834         return ret_arr;
15835 }
15836
15837 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
15838         LDKu8slice ser_ref;
15839         ser_ref.datalen = *((uint32_t*)ser);
15840         ser_ref.data = (int8_t*)(ser + 4);
15841         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15842         *ret_conv = ChannelAnnouncement_read(ser_ref);
15843         return (long)ret_conv;
15844 }
15845
15846 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
15847         LDKUnsignedChannelUpdate obj_conv;
15848         obj_conv.inner = (void*)(obj & (~1));
15849         obj_conv.is_owned = false;
15850         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
15851         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15852         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15853         CVec_u8Z_free(ret_var);
15854         return ret_arr;
15855 }
15856
15857 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
15858         LDKu8slice ser_ref;
15859         ser_ref.datalen = *((uint32_t*)ser);
15860         ser_ref.data = (int8_t*)(ser + 4);
15861         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15862         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
15863         return (long)ret_conv;
15864 }
15865
15866 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
15867         LDKChannelUpdate obj_conv;
15868         obj_conv.inner = (void*)(obj & (~1));
15869         obj_conv.is_owned = false;
15870         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
15871         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15872         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15873         CVec_u8Z_free(ret_var);
15874         return ret_arr;
15875 }
15876
15877 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
15878         LDKu8slice ser_ref;
15879         ser_ref.datalen = *((uint32_t*)ser);
15880         ser_ref.data = (int8_t*)(ser + 4);
15881         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15882         *ret_conv = ChannelUpdate_read(ser_ref);
15883         return (long)ret_conv;
15884 }
15885
15886 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
15887         LDKErrorMessage obj_conv;
15888         obj_conv.inner = (void*)(obj & (~1));
15889         obj_conv.is_owned = false;
15890         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
15891         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15892         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15893         CVec_u8Z_free(ret_var);
15894         return ret_arr;
15895 }
15896
15897 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
15898         LDKu8slice ser_ref;
15899         ser_ref.datalen = *((uint32_t*)ser);
15900         ser_ref.data = (int8_t*)(ser + 4);
15901         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15902         *ret_conv = ErrorMessage_read(ser_ref);
15903         return (long)ret_conv;
15904 }
15905
15906 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
15907         LDKUnsignedNodeAnnouncement obj_conv;
15908         obj_conv.inner = (void*)(obj & (~1));
15909         obj_conv.is_owned = false;
15910         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
15911         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15912         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15913         CVec_u8Z_free(ret_var);
15914         return ret_arr;
15915 }
15916
15917 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
15918         LDKu8slice ser_ref;
15919         ser_ref.datalen = *((uint32_t*)ser);
15920         ser_ref.data = (int8_t*)(ser + 4);
15921         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15922         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
15923         return (long)ret_conv;
15924 }
15925
15926 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
15927         LDKNodeAnnouncement obj_conv;
15928         obj_conv.inner = (void*)(obj & (~1));
15929         obj_conv.is_owned = false;
15930         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
15931         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15932         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15933         CVec_u8Z_free(ret_var);
15934         return ret_arr;
15935 }
15936
15937 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
15938         LDKu8slice ser_ref;
15939         ser_ref.datalen = *((uint32_t*)ser);
15940         ser_ref.data = (int8_t*)(ser + 4);
15941         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15942         *ret_conv = NodeAnnouncement_read(ser_ref);
15943         return (long)ret_conv;
15944 }
15945
15946 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
15947         LDKu8slice ser_ref;
15948         ser_ref.datalen = *((uint32_t*)ser);
15949         ser_ref.data = (int8_t*)(ser + 4);
15950         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15951         *ret_conv = QueryShortChannelIds_read(ser_ref);
15952         return (long)ret_conv;
15953 }
15954
15955 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
15956         LDKQueryShortChannelIds obj_conv;
15957         obj_conv.inner = (void*)(obj & (~1));
15958         obj_conv.is_owned = false;
15959         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
15960         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15961         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15962         CVec_u8Z_free(ret_var);
15963         return ret_arr;
15964 }
15965
15966 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
15967         LDKu8slice ser_ref;
15968         ser_ref.datalen = *((uint32_t*)ser);
15969         ser_ref.data = (int8_t*)(ser + 4);
15970         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15971         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
15972         return (long)ret_conv;
15973 }
15974
15975 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
15976         LDKReplyShortChannelIdsEnd obj_conv;
15977         obj_conv.inner = (void*)(obj & (~1));
15978         obj_conv.is_owned = false;
15979         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
15980         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15981         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15982         CVec_u8Z_free(ret_var);
15983         return ret_arr;
15984 }
15985
15986 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
15987         LDKQueryChannelRange this_arg_conv;
15988         this_arg_conv.inner = (void*)(this_arg & (~1));
15989         this_arg_conv.is_owned = false;
15990         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
15991         return ret_val;
15992 }
15993
15994 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
15995         LDKu8slice ser_ref;
15996         ser_ref.datalen = *((uint32_t*)ser);
15997         ser_ref.data = (int8_t*)(ser + 4);
15998         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15999         *ret_conv = QueryChannelRange_read(ser_ref);
16000         return (long)ret_conv;
16001 }
16002
16003 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
16004         LDKQueryChannelRange obj_conv;
16005         obj_conv.inner = (void*)(obj & (~1));
16006         obj_conv.is_owned = false;
16007         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
16008         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16009         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16010         CVec_u8Z_free(ret_var);
16011         return ret_arr;
16012 }
16013
16014 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
16015         LDKu8slice ser_ref;
16016         ser_ref.datalen = *((uint32_t*)ser);
16017         ser_ref.data = (int8_t*)(ser + 4);
16018         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16019         *ret_conv = ReplyChannelRange_read(ser_ref);
16020         return (long)ret_conv;
16021 }
16022
16023 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
16024         LDKReplyChannelRange obj_conv;
16025         obj_conv.inner = (void*)(obj & (~1));
16026         obj_conv.is_owned = false;
16027         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
16028         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16029         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16030         CVec_u8Z_free(ret_var);
16031         return ret_arr;
16032 }
16033
16034 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
16035         LDKu8slice ser_ref;
16036         ser_ref.datalen = *((uint32_t*)ser);
16037         ser_ref.data = (int8_t*)(ser + 4);
16038         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16039         *ret_conv = GossipTimestampFilter_read(ser_ref);
16040         return (long)ret_conv;
16041 }
16042
16043 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
16044         LDKGossipTimestampFilter obj_conv;
16045         obj_conv.inner = (void*)(obj & (~1));
16046         obj_conv.is_owned = false;
16047         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
16048         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16049         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16050         CVec_u8Z_free(ret_var);
16051         return ret_arr;
16052 }
16053
16054 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
16055         LDKIgnoringMessageHandler this_obj_conv;
16056         this_obj_conv.inner = (void*)(this_obj & (~1));
16057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16058         IgnoringMessageHandler_free(this_obj_conv);
16059 }
16060
16061 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
16062         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
16063         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16064         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16065         long ret_ref = (long)ret_var.inner;
16066         if (ret_var.is_owned) {
16067                 ret_ref |= 1;
16068         }
16069         return ret_ref;
16070 }
16071
16072 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
16073         LDKIgnoringMessageHandler this_arg_conv;
16074         this_arg_conv.inner = (void*)(this_arg & (~1));
16075         this_arg_conv.is_owned = false;
16076         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16077         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16078         return (long)ret;
16079 }
16080
16081 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
16082         LDKIgnoringMessageHandler this_arg_conv;
16083         this_arg_conv.inner = (void*)(this_arg & (~1));
16084         this_arg_conv.is_owned = false;
16085         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
16086         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
16087         return (long)ret;
16088 }
16089
16090 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
16091         LDKErroringMessageHandler this_obj_conv;
16092         this_obj_conv.inner = (void*)(this_obj & (~1));
16093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16094         ErroringMessageHandler_free(this_obj_conv);
16095 }
16096
16097 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
16098         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
16099         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16100         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16101         long ret_ref = (long)ret_var.inner;
16102         if (ret_var.is_owned) {
16103                 ret_ref |= 1;
16104         }
16105         return ret_ref;
16106 }
16107
16108 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
16109         LDKErroringMessageHandler this_arg_conv;
16110         this_arg_conv.inner = (void*)(this_arg & (~1));
16111         this_arg_conv.is_owned = false;
16112         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16113         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16114         return (long)ret;
16115 }
16116
16117 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
16118         LDKErroringMessageHandler this_arg_conv;
16119         this_arg_conv.inner = (void*)(this_arg & (~1));
16120         this_arg_conv.is_owned = false;
16121         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16122         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
16123         return (long)ret;
16124 }
16125
16126 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
16127         LDKMessageHandler this_obj_conv;
16128         this_obj_conv.inner = (void*)(this_obj & (~1));
16129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16130         MessageHandler_free(this_obj_conv);
16131 }
16132
16133 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
16134         LDKMessageHandler this_ptr_conv;
16135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16136         this_ptr_conv.is_owned = false;
16137         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
16138         return ret_ret;
16139 }
16140
16141 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
16142         LDKMessageHandler this_ptr_conv;
16143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16144         this_ptr_conv.is_owned = false;
16145         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
16146         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
16147 }
16148
16149 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
16150         LDKMessageHandler this_ptr_conv;
16151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16152         this_ptr_conv.is_owned = false;
16153         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
16154         return ret_ret;
16155 }
16156
16157 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
16158         LDKMessageHandler this_ptr_conv;
16159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16160         this_ptr_conv.is_owned = false;
16161         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
16162         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
16163 }
16164
16165 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
16166         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
16167         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
16168         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
16169         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16170         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16171         long ret_ref = (long)ret_var.inner;
16172         if (ret_var.is_owned) {
16173                 ret_ref |= 1;
16174         }
16175         return ret_ref;
16176 }
16177
16178 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
16179         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
16180         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
16181         *ret = SocketDescriptor_clone(orig_conv);
16182         return (long)ret;
16183 }
16184
16185 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
16186         if ((this_ptr & 1) != 0) return;
16187         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
16188         FREE((void*)this_ptr);
16189         SocketDescriptor_free(this_ptr_conv);
16190 }
16191
16192 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
16193         LDKPeerHandleError this_obj_conv;
16194         this_obj_conv.inner = (void*)(this_obj & (~1));
16195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16196         PeerHandleError_free(this_obj_conv);
16197 }
16198
16199 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
16200         LDKPeerHandleError this_ptr_conv;
16201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16202         this_ptr_conv.is_owned = false;
16203         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
16204         return ret_val;
16205 }
16206
16207 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
16208         LDKPeerHandleError this_ptr_conv;
16209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16210         this_ptr_conv.is_owned = false;
16211         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
16212 }
16213
16214 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
16215         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
16216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16218         long ret_ref = (long)ret_var.inner;
16219         if (ret_var.is_owned) {
16220                 ret_ref |= 1;
16221         }
16222         return ret_ref;
16223 }
16224
16225 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
16226         LDKPeerHandleError orig_conv;
16227         orig_conv.inner = (void*)(orig & (~1));
16228         orig_conv.is_owned = false;
16229         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
16230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16232         long ret_ref = (long)ret_var.inner;
16233         if (ret_var.is_owned) {
16234                 ret_ref |= 1;
16235         }
16236         return ret_ref;
16237 }
16238
16239 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
16240         LDKPeerManager this_obj_conv;
16241         this_obj_conv.inner = (void*)(this_obj & (~1));
16242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16243         PeerManager_free(this_obj_conv);
16244 }
16245
16246 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) {
16247         LDKMessageHandler message_handler_conv;
16248         message_handler_conv.inner = (void*)(message_handler & (~1));
16249         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
16250         // Warning: we need a move here but no clone is available for LDKMessageHandler
16251         LDKSecretKey our_node_secret_ref;
16252         CHECK(*((uint32_t*)our_node_secret) == 32);
16253         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
16254         unsigned char ephemeral_random_data_arr[32];
16255         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
16256         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
16257         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
16258         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16259         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
16260         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16261         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16262         long ret_ref = (long)ret_var.inner;
16263         if (ret_var.is_owned) {
16264                 ret_ref |= 1;
16265         }
16266         return ret_ref;
16267 }
16268
16269 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
16270         LDKPeerManager this_arg_conv;
16271         this_arg_conv.inner = (void*)(this_arg & (~1));
16272         this_arg_conv.is_owned = false;
16273         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
16274         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
16275         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
16276         for (size_t m = 0; m < ret_var.datalen; m++) {
16277                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16278                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
16279                 ret_arr_ptr[m] = ret_conv_12_arr;
16280         }
16281         FREE(ret_var.data);
16282         return ret_arr;
16283 }
16284
16285 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
16286         LDKPeerManager this_arg_conv;
16287         this_arg_conv.inner = (void*)(this_arg & (~1));
16288         this_arg_conv.is_owned = false;
16289         LDKPublicKey their_node_id_ref;
16290         CHECK(*((uint32_t*)their_node_id) == 33);
16291         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
16292         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16293         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16294         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
16295         return (long)ret_conv;
16296 }
16297
16298 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
16299         LDKPeerManager this_arg_conv;
16300         this_arg_conv.inner = (void*)(this_arg & (~1));
16301         this_arg_conv.is_owned = false;
16302         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16303         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16304         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
16305         return (long)ret_conv;
16306 }
16307
16308 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
16309         LDKPeerManager this_arg_conv;
16310         this_arg_conv.inner = (void*)(this_arg & (~1));
16311         this_arg_conv.is_owned = false;
16312         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16313         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16314         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
16315         return (long)ret_conv;
16316 }
16317
16318 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
16319         LDKPeerManager this_arg_conv;
16320         this_arg_conv.inner = (void*)(this_arg & (~1));
16321         this_arg_conv.is_owned = false;
16322         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
16323         LDKu8slice data_ref;
16324         data_ref.datalen = *((uint32_t*)data);
16325         data_ref.data = (int8_t*)(data + 4);
16326         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16327         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
16328         return (long)ret_conv;
16329 }
16330
16331 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
16332         LDKPeerManager this_arg_conv;
16333         this_arg_conv.inner = (void*)(this_arg & (~1));
16334         this_arg_conv.is_owned = false;
16335         PeerManager_process_events(&this_arg_conv);
16336 }
16337
16338 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
16339         LDKPeerManager this_arg_conv;
16340         this_arg_conv.inner = (void*)(this_arg & (~1));
16341         this_arg_conv.is_owned = false;
16342         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16343         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
16344 }
16345
16346 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
16347         LDKPeerManager this_arg_conv;
16348         this_arg_conv.inner = (void*)(this_arg & (~1));
16349         this_arg_conv.is_owned = false;
16350         LDKPublicKey node_id_ref;
16351         CHECK(*((uint32_t*)node_id) == 33);
16352         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16353         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
16354 }
16355
16356 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
16357         LDKPeerManager this_arg_conv;
16358         this_arg_conv.inner = (void*)(this_arg & (~1));
16359         this_arg_conv.is_owned = false;
16360         PeerManager_timer_tick_occurred(&this_arg_conv);
16361 }
16362
16363 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
16364         unsigned char commitment_seed_arr[32];
16365         CHECK(*((uint32_t*)commitment_seed) == 32);
16366         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
16367         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
16368         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16369         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
16370         return ret_arr;
16371 }
16372
16373 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
16374         LDKPublicKey per_commitment_point_ref;
16375         CHECK(*((uint32_t*)per_commitment_point) == 33);
16376         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16377         unsigned char base_secret_arr[32];
16378         CHECK(*((uint32_t*)base_secret) == 32);
16379         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
16380         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
16381         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16382         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
16383         return (long)ret_conv;
16384 }
16385
16386 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
16387         LDKPublicKey per_commitment_point_ref;
16388         CHECK(*((uint32_t*)per_commitment_point) == 33);
16389         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16390         LDKPublicKey base_point_ref;
16391         CHECK(*((uint32_t*)base_point) == 33);
16392         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
16393         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16394         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
16395         return (long)ret_conv;
16396 }
16397
16398 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
16399         unsigned char per_commitment_secret_arr[32];
16400         CHECK(*((uint32_t*)per_commitment_secret) == 32);
16401         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
16402         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
16403         unsigned char countersignatory_revocation_base_secret_arr[32];
16404         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
16405         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
16406         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
16407         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16408         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
16409         return (long)ret_conv;
16410 }
16411
16412 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
16413         LDKPublicKey per_commitment_point_ref;
16414         CHECK(*((uint32_t*)per_commitment_point) == 33);
16415         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16416         LDKPublicKey countersignatory_revocation_base_point_ref;
16417         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
16418         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
16419         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16420         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
16421         return (long)ret_conv;
16422 }
16423
16424 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
16425         LDKTxCreationKeys this_obj_conv;
16426         this_obj_conv.inner = (void*)(this_obj & (~1));
16427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16428         TxCreationKeys_free(this_obj_conv);
16429 }
16430
16431 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
16432         LDKTxCreationKeys this_ptr_conv;
16433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16434         this_ptr_conv.is_owned = false;
16435         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16436         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16437         return ret_arr;
16438 }
16439
16440 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16441         LDKTxCreationKeys this_ptr_conv;
16442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16443         this_ptr_conv.is_owned = false;
16444         LDKPublicKey val_ref;
16445         CHECK(*((uint32_t*)val) == 33);
16446         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16447         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
16448 }
16449
16450 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
16451         LDKTxCreationKeys this_ptr_conv;
16452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16453         this_ptr_conv.is_owned = false;
16454         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16455         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
16456         return ret_arr;
16457 }
16458
16459 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
16460         LDKTxCreationKeys this_ptr_conv;
16461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16462         this_ptr_conv.is_owned = false;
16463         LDKPublicKey val_ref;
16464         CHECK(*((uint32_t*)val) == 33);
16465         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16466         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
16467 }
16468
16469 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
16470         LDKTxCreationKeys this_ptr_conv;
16471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16472         this_ptr_conv.is_owned = false;
16473         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16474         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
16475         return ret_arr;
16476 }
16477
16478 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
16479         LDKTxCreationKeys this_ptr_conv;
16480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16481         this_ptr_conv.is_owned = false;
16482         LDKPublicKey val_ref;
16483         CHECK(*((uint32_t*)val) == 33);
16484         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16485         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
16486 }
16487
16488 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
16489         LDKTxCreationKeys this_ptr_conv;
16490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16491         this_ptr_conv.is_owned = false;
16492         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16493         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
16494         return ret_arr;
16495 }
16496
16497 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
16498         LDKTxCreationKeys this_ptr_conv;
16499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16500         this_ptr_conv.is_owned = false;
16501         LDKPublicKey val_ref;
16502         CHECK(*((uint32_t*)val) == 33);
16503         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16504         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
16505 }
16506
16507 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
16508         LDKTxCreationKeys this_ptr_conv;
16509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16510         this_ptr_conv.is_owned = false;
16511         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16512         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
16513         return ret_arr;
16514 }
16515
16516 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
16517         LDKTxCreationKeys this_ptr_conv;
16518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16519         this_ptr_conv.is_owned = false;
16520         LDKPublicKey val_ref;
16521         CHECK(*((uint32_t*)val) == 33);
16522         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16523         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
16524 }
16525
16526 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_new(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) {
16527         LDKPublicKey per_commitment_point_arg_ref;
16528         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
16529         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
16530         LDKPublicKey revocation_key_arg_ref;
16531         CHECK(*((uint32_t*)revocation_key_arg) == 33);
16532         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
16533         LDKPublicKey broadcaster_htlc_key_arg_ref;
16534         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
16535         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
16536         LDKPublicKey countersignatory_htlc_key_arg_ref;
16537         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
16538         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
16539         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
16540         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
16541         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
16542         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);
16543         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16544         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16545         long ret_ref = (long)ret_var.inner;
16546         if (ret_var.is_owned) {
16547                 ret_ref |= 1;
16548         }
16549         return ret_ref;
16550 }
16551
16552 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
16553         LDKTxCreationKeys orig_conv;
16554         orig_conv.inner = (void*)(orig & (~1));
16555         orig_conv.is_owned = false;
16556         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
16557         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16558         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16559         long ret_ref = (long)ret_var.inner;
16560         if (ret_var.is_owned) {
16561                 ret_ref |= 1;
16562         }
16563         return ret_ref;
16564 }
16565
16566 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
16567         LDKTxCreationKeys obj_conv;
16568         obj_conv.inner = (void*)(obj & (~1));
16569         obj_conv.is_owned = false;
16570         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
16571         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16572         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16573         CVec_u8Z_free(ret_var);
16574         return ret_arr;
16575 }
16576
16577 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
16578         LDKu8slice ser_ref;
16579         ser_ref.datalen = *((uint32_t*)ser);
16580         ser_ref.data = (int8_t*)(ser + 4);
16581         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16582         *ret_conv = TxCreationKeys_read(ser_ref);
16583         return (long)ret_conv;
16584 }
16585
16586 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
16587         LDKChannelPublicKeys this_obj_conv;
16588         this_obj_conv.inner = (void*)(this_obj & (~1));
16589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16590         ChannelPublicKeys_free(this_obj_conv);
16591 }
16592
16593 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
16594         LDKChannelPublicKeys this_ptr_conv;
16595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16596         this_ptr_conv.is_owned = false;
16597         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16598         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16599         return ret_arr;
16600 }
16601
16602 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16603         LDKChannelPublicKeys this_ptr_conv;
16604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16605         this_ptr_conv.is_owned = false;
16606         LDKPublicKey val_ref;
16607         CHECK(*((uint32_t*)val) == 33);
16608         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16609         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
16610 }
16611
16612 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
16613         LDKChannelPublicKeys this_ptr_conv;
16614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16615         this_ptr_conv.is_owned = false;
16616         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16617         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16618         return ret_arr;
16619 }
16620
16621 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16622         LDKChannelPublicKeys this_ptr_conv;
16623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16624         this_ptr_conv.is_owned = false;
16625         LDKPublicKey val_ref;
16626         CHECK(*((uint32_t*)val) == 33);
16627         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16628         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
16629 }
16630
16631 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
16632         LDKChannelPublicKeys this_ptr_conv;
16633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16634         this_ptr_conv.is_owned = false;
16635         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16636         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
16637         return ret_arr;
16638 }
16639
16640 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16641         LDKChannelPublicKeys this_ptr_conv;
16642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16643         this_ptr_conv.is_owned = false;
16644         LDKPublicKey val_ref;
16645         CHECK(*((uint32_t*)val) == 33);
16646         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16647         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
16648 }
16649
16650 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
16651         LDKChannelPublicKeys this_ptr_conv;
16652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16653         this_ptr_conv.is_owned = false;
16654         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16655         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16656         return ret_arr;
16657 }
16658
16659 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16660         LDKChannelPublicKeys this_ptr_conv;
16661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16662         this_ptr_conv.is_owned = false;
16663         LDKPublicKey val_ref;
16664         CHECK(*((uint32_t*)val) == 33);
16665         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16666         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16667 }
16668
16669 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
16670         LDKChannelPublicKeys this_ptr_conv;
16671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16672         this_ptr_conv.is_owned = false;
16673         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16674         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16675         return ret_arr;
16676 }
16677
16678 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16679         LDKChannelPublicKeys this_ptr_conv;
16680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16681         this_ptr_conv.is_owned = false;
16682         LDKPublicKey val_ref;
16683         CHECK(*((uint32_t*)val) == 33);
16684         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16685         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
16686 }
16687
16688 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_new(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) {
16689         LDKPublicKey funding_pubkey_arg_ref;
16690         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
16691         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
16692         LDKPublicKey revocation_basepoint_arg_ref;
16693         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
16694         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
16695         LDKPublicKey payment_point_arg_ref;
16696         CHECK(*((uint32_t*)payment_point_arg) == 33);
16697         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
16698         LDKPublicKey delayed_payment_basepoint_arg_ref;
16699         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
16700         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
16701         LDKPublicKey htlc_basepoint_arg_ref;
16702         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
16703         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
16704         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);
16705         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16706         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16707         long ret_ref = (long)ret_var.inner;
16708         if (ret_var.is_owned) {
16709                 ret_ref |= 1;
16710         }
16711         return ret_ref;
16712 }
16713
16714 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
16715         LDKChannelPublicKeys orig_conv;
16716         orig_conv.inner = (void*)(orig & (~1));
16717         orig_conv.is_owned = false;
16718         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
16719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16721         long ret_ref = (long)ret_var.inner;
16722         if (ret_var.is_owned) {
16723                 ret_ref |= 1;
16724         }
16725         return ret_ref;
16726 }
16727
16728 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
16729         LDKChannelPublicKeys obj_conv;
16730         obj_conv.inner = (void*)(obj & (~1));
16731         obj_conv.is_owned = false;
16732         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
16733         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16734         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16735         CVec_u8Z_free(ret_var);
16736         return ret_arr;
16737 }
16738
16739 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
16740         LDKu8slice ser_ref;
16741         ser_ref.datalen = *((uint32_t*)ser);
16742         ser_ref.data = (int8_t*)(ser + 4);
16743         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16744         *ret_conv = ChannelPublicKeys_read(ser_ref);
16745         return (long)ret_conv;
16746 }
16747
16748 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_derive_new(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) {
16749         LDKPublicKey per_commitment_point_ref;
16750         CHECK(*((uint32_t*)per_commitment_point) == 33);
16751         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16752         LDKPublicKey broadcaster_delayed_payment_base_ref;
16753         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
16754         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
16755         LDKPublicKey broadcaster_htlc_base_ref;
16756         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
16757         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
16758         LDKPublicKey countersignatory_revocation_base_ref;
16759         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
16760         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
16761         LDKPublicKey countersignatory_htlc_base_ref;
16762         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
16763         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
16764         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16765         *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);
16766         return (long)ret_conv;
16767 }
16768
16769 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
16770         LDKPublicKey per_commitment_point_ref;
16771         CHECK(*((uint32_t*)per_commitment_point) == 33);
16772         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16773         LDKChannelPublicKeys broadcaster_keys_conv;
16774         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
16775         broadcaster_keys_conv.is_owned = false;
16776         LDKChannelPublicKeys countersignatory_keys_conv;
16777         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
16778         countersignatory_keys_conv.is_owned = false;
16779         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16780         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
16781         return (long)ret_conv;
16782 }
16783
16784 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
16785         LDKPublicKey revocation_key_ref;
16786         CHECK(*((uint32_t*)revocation_key) == 33);
16787         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16788         LDKPublicKey broadcaster_delayed_payment_key_ref;
16789         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16790         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16791         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
16792         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16793         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16794         CVec_u8Z_free(ret_var);
16795         return ret_arr;
16796 }
16797
16798 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
16799         LDKHTLCOutputInCommitment this_obj_conv;
16800         this_obj_conv.inner = (void*)(this_obj & (~1));
16801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16802         HTLCOutputInCommitment_free(this_obj_conv);
16803 }
16804
16805 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
16806         LDKHTLCOutputInCommitment this_ptr_conv;
16807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16808         this_ptr_conv.is_owned = false;
16809         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
16810         return ret_val;
16811 }
16812
16813 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
16814         LDKHTLCOutputInCommitment this_ptr_conv;
16815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16816         this_ptr_conv.is_owned = false;
16817         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
16818 }
16819
16820 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
16821         LDKHTLCOutputInCommitment this_ptr_conv;
16822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16823         this_ptr_conv.is_owned = false;
16824         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
16825         return ret_val;
16826 }
16827
16828 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
16829         LDKHTLCOutputInCommitment this_ptr_conv;
16830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16831         this_ptr_conv.is_owned = false;
16832         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
16833 }
16834
16835 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
16836         LDKHTLCOutputInCommitment this_ptr_conv;
16837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16838         this_ptr_conv.is_owned = false;
16839         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
16840         return ret_val;
16841 }
16842
16843 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
16844         LDKHTLCOutputInCommitment this_ptr_conv;
16845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16846         this_ptr_conv.is_owned = false;
16847         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
16848 }
16849
16850 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
16851         LDKHTLCOutputInCommitment this_ptr_conv;
16852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16853         this_ptr_conv.is_owned = false;
16854         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16855         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
16856         return ret_arr;
16857 }
16858
16859 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
16860         LDKHTLCOutputInCommitment this_ptr_conv;
16861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16862         this_ptr_conv.is_owned = false;
16863         LDKThirtyTwoBytes val_ref;
16864         CHECK(*((uint32_t*)val) == 32);
16865         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16866         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
16867 }
16868
16869 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
16870         LDKHTLCOutputInCommitment this_ptr_conv;
16871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16872         this_ptr_conv.is_owned = false;
16873         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16874         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
16875         long ret_ref = (long)ret_copy;
16876         return ret_ref;
16877 }
16878
16879 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
16880         LDKHTLCOutputInCommitment this_ptr_conv;
16881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16882         this_ptr_conv.is_owned = false;
16883         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16884         FREE((void*)val);
16885         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
16886 }
16887
16888 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, uint32_t transaction_output_index_arg) {
16889         LDKThirtyTwoBytes payment_hash_arg_ref;
16890         CHECK(*((uint32_t*)payment_hash_arg) == 32);
16891         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
16892         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
16893         FREE((void*)transaction_output_index_arg);
16894         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
16895         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16896         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16897         long ret_ref = (long)ret_var.inner;
16898         if (ret_var.is_owned) {
16899                 ret_ref |= 1;
16900         }
16901         return ret_ref;
16902 }
16903
16904 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
16905         LDKHTLCOutputInCommitment orig_conv;
16906         orig_conv.inner = (void*)(orig & (~1));
16907         orig_conv.is_owned = false;
16908         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
16909         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16910         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16911         long ret_ref = (long)ret_var.inner;
16912         if (ret_var.is_owned) {
16913                 ret_ref |= 1;
16914         }
16915         return ret_ref;
16916 }
16917
16918 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
16919         LDKHTLCOutputInCommitment obj_conv;
16920         obj_conv.inner = (void*)(obj & (~1));
16921         obj_conv.is_owned = false;
16922         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
16923         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16924         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16925         CVec_u8Z_free(ret_var);
16926         return ret_arr;
16927 }
16928
16929 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
16930         LDKu8slice ser_ref;
16931         ser_ref.datalen = *((uint32_t*)ser);
16932         ser_ref.data = (int8_t*)(ser + 4);
16933         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16934         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
16935         return (long)ret_conv;
16936 }
16937
16938 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
16939         LDKHTLCOutputInCommitment htlc_conv;
16940         htlc_conv.inner = (void*)(htlc & (~1));
16941         htlc_conv.is_owned = false;
16942         LDKTxCreationKeys keys_conv;
16943         keys_conv.inner = (void*)(keys & (~1));
16944         keys_conv.is_owned = false;
16945         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
16946         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16947         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16948         CVec_u8Z_free(ret_var);
16949         return ret_arr;
16950 }
16951
16952 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
16953         LDKPublicKey broadcaster_ref;
16954         CHECK(*((uint32_t*)broadcaster) == 33);
16955         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
16956         LDKPublicKey countersignatory_ref;
16957         CHECK(*((uint32_t*)countersignatory) == 33);
16958         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
16959         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
16960         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16961         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16962         CVec_u8Z_free(ret_var);
16963         return ret_arr;
16964 }
16965
16966 int8_tArray  __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray prev_hash, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
16967         unsigned char prev_hash_arr[32];
16968         CHECK(*((uint32_t*)prev_hash) == 32);
16969         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
16970         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
16971         LDKHTLCOutputInCommitment htlc_conv;
16972         htlc_conv.inner = (void*)(htlc & (~1));
16973         htlc_conv.is_owned = false;
16974         LDKPublicKey broadcaster_delayed_payment_key_ref;
16975         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16976         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16977         LDKPublicKey revocation_key_ref;
16978         CHECK(*((uint32_t*)revocation_key) == 33);
16979         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16980         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
16981         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16982         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16983         Transaction_free(ret_var);
16984         return ret_arr;
16985 }
16986
16987 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
16988         LDKChannelTransactionParameters this_obj_conv;
16989         this_obj_conv.inner = (void*)(this_obj & (~1));
16990         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16991         ChannelTransactionParameters_free(this_obj_conv);
16992 }
16993
16994 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
16995         LDKChannelTransactionParameters this_ptr_conv;
16996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16997         this_ptr_conv.is_owned = false;
16998         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
16999         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17000         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17001         long ret_ref = (long)ret_var.inner;
17002         if (ret_var.is_owned) {
17003                 ret_ref |= 1;
17004         }
17005         return ret_ref;
17006 }
17007
17008 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
17009         LDKChannelTransactionParameters this_ptr_conv;
17010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17011         this_ptr_conv.is_owned = false;
17012         LDKChannelPublicKeys val_conv;
17013         val_conv.inner = (void*)(val & (~1));
17014         val_conv.is_owned = (val & 1) || (val == 0);
17015         val_conv = ChannelPublicKeys_clone(&val_conv);
17016         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
17017 }
17018
17019 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
17020         LDKChannelTransactionParameters this_ptr_conv;
17021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17022         this_ptr_conv.is_owned = false;
17023         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
17024         return ret_val;
17025 }
17026
17027 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
17028         LDKChannelTransactionParameters this_ptr_conv;
17029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17030         this_ptr_conv.is_owned = false;
17031         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
17032 }
17033
17034 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
17035         LDKChannelTransactionParameters this_ptr_conv;
17036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17037         this_ptr_conv.is_owned = false;
17038         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
17039         return ret_val;
17040 }
17041
17042 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
17043         LDKChannelTransactionParameters this_ptr_conv;
17044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17045         this_ptr_conv.is_owned = false;
17046         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
17047 }
17048
17049 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
17050         LDKChannelTransactionParameters this_ptr_conv;
17051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17052         this_ptr_conv.is_owned = false;
17053         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
17054         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17055         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17056         long ret_ref = (long)ret_var.inner;
17057         if (ret_var.is_owned) {
17058                 ret_ref |= 1;
17059         }
17060         return ret_ref;
17061 }
17062
17063 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
17064         LDKChannelTransactionParameters this_ptr_conv;
17065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17066         this_ptr_conv.is_owned = false;
17067         LDKCounterpartyChannelTransactionParameters val_conv;
17068         val_conv.inner = (void*)(val & (~1));
17069         val_conv.is_owned = (val & 1) || (val == 0);
17070         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
17071         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
17072 }
17073
17074 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
17075         LDKChannelTransactionParameters this_ptr_conv;
17076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17077         this_ptr_conv.is_owned = false;
17078         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
17079         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17080         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17081         long ret_ref = (long)ret_var.inner;
17082         if (ret_var.is_owned) {
17083                 ret_ref |= 1;
17084         }
17085         return ret_ref;
17086 }
17087
17088 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
17089         LDKChannelTransactionParameters this_ptr_conv;
17090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17091         this_ptr_conv.is_owned = false;
17092         LDKOutPoint val_conv;
17093         val_conv.inner = (void*)(val & (~1));
17094         val_conv.is_owned = (val & 1) || (val == 0);
17095         val_conv = OutPoint_clone(&val_conv);
17096         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
17097 }
17098
17099 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_new(uint32_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint32_t counterparty_parameters_arg, uint32_t funding_outpoint_arg) {
17100         LDKChannelPublicKeys holder_pubkeys_arg_conv;
17101         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
17102         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
17103         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
17104         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
17105         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
17106         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
17107         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
17108         LDKOutPoint funding_outpoint_arg_conv;
17109         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
17110         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
17111         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
17112         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);
17113         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17114         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17115         long ret_ref = (long)ret_var.inner;
17116         if (ret_var.is_owned) {
17117                 ret_ref |= 1;
17118         }
17119         return ret_ref;
17120 }
17121
17122 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
17123         LDKChannelTransactionParameters orig_conv;
17124         orig_conv.inner = (void*)(orig & (~1));
17125         orig_conv.is_owned = false;
17126         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
17127         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17128         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17129         long ret_ref = (long)ret_var.inner;
17130         if (ret_var.is_owned) {
17131                 ret_ref |= 1;
17132         }
17133         return ret_ref;
17134 }
17135
17136 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
17137         LDKCounterpartyChannelTransactionParameters this_obj_conv;
17138         this_obj_conv.inner = (void*)(this_obj & (~1));
17139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17140         CounterpartyChannelTransactionParameters_free(this_obj_conv);
17141 }
17142
17143 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
17144         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17146         this_ptr_conv.is_owned = false;
17147         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
17148         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17149         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17150         long ret_ref = (long)ret_var.inner;
17151         if (ret_var.is_owned) {
17152                 ret_ref |= 1;
17153         }
17154         return ret_ref;
17155 }
17156
17157 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
17158         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17160         this_ptr_conv.is_owned = false;
17161         LDKChannelPublicKeys val_conv;
17162         val_conv.inner = (void*)(val & (~1));
17163         val_conv.is_owned = (val & 1) || (val == 0);
17164         val_conv = ChannelPublicKeys_clone(&val_conv);
17165         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
17166 }
17167
17168 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
17169         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17171         this_ptr_conv.is_owned = false;
17172         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
17173         return ret_val;
17174 }
17175
17176 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
17177         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17179         this_ptr_conv.is_owned = false;
17180         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
17181 }
17182
17183 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
17184         LDKChannelPublicKeys pubkeys_arg_conv;
17185         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
17186         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
17187         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
17188         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
17189         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17190         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17191         long ret_ref = (long)ret_var.inner;
17192         if (ret_var.is_owned) {
17193                 ret_ref |= 1;
17194         }
17195         return ret_ref;
17196 }
17197
17198 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
17199         LDKCounterpartyChannelTransactionParameters orig_conv;
17200         orig_conv.inner = (void*)(orig & (~1));
17201         orig_conv.is_owned = false;
17202         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
17203         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17204         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17205         long ret_ref = (long)ret_var.inner;
17206         if (ret_var.is_owned) {
17207                 ret_ref |= 1;
17208         }
17209         return ret_ref;
17210 }
17211
17212 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
17213         LDKChannelTransactionParameters this_arg_conv;
17214         this_arg_conv.inner = (void*)(this_arg & (~1));
17215         this_arg_conv.is_owned = false;
17216         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
17217         return ret_val;
17218 }
17219
17220 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
17221         LDKChannelTransactionParameters this_arg_conv;
17222         this_arg_conv.inner = (void*)(this_arg & (~1));
17223         this_arg_conv.is_owned = false;
17224         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
17225         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17226         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17227         long ret_ref = (long)ret_var.inner;
17228         if (ret_var.is_owned) {
17229                 ret_ref |= 1;
17230         }
17231         return ret_ref;
17232 }
17233
17234 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
17235         LDKChannelTransactionParameters this_arg_conv;
17236         this_arg_conv.inner = (void*)(this_arg & (~1));
17237         this_arg_conv.is_owned = false;
17238         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
17239         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17240         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17241         long ret_ref = (long)ret_var.inner;
17242         if (ret_var.is_owned) {
17243                 ret_ref |= 1;
17244         }
17245         return ret_ref;
17246 }
17247
17248 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
17249         LDKCounterpartyChannelTransactionParameters obj_conv;
17250         obj_conv.inner = (void*)(obj & (~1));
17251         obj_conv.is_owned = false;
17252         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
17253         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17254         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17255         CVec_u8Z_free(ret_var);
17256         return ret_arr;
17257 }
17258
17259 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
17260         LDKu8slice ser_ref;
17261         ser_ref.datalen = *((uint32_t*)ser);
17262         ser_ref.data = (int8_t*)(ser + 4);
17263         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
17264         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
17265         return (long)ret_conv;
17266 }
17267
17268 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
17269         LDKChannelTransactionParameters obj_conv;
17270         obj_conv.inner = (void*)(obj & (~1));
17271         obj_conv.is_owned = false;
17272         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
17273         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17274         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17275         CVec_u8Z_free(ret_var);
17276         return ret_arr;
17277 }
17278
17279 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
17280         LDKu8slice ser_ref;
17281         ser_ref.datalen = *((uint32_t*)ser);
17282         ser_ref.data = (int8_t*)(ser + 4);
17283         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
17284         *ret_conv = ChannelTransactionParameters_read(ser_ref);
17285         return (long)ret_conv;
17286 }
17287
17288 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
17289         LDKDirectedChannelTransactionParameters this_obj_conv;
17290         this_obj_conv.inner = (void*)(this_obj & (~1));
17291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17292         DirectedChannelTransactionParameters_free(this_obj_conv);
17293 }
17294
17295 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
17296         LDKDirectedChannelTransactionParameters this_arg_conv;
17297         this_arg_conv.inner = (void*)(this_arg & (~1));
17298         this_arg_conv.is_owned = false;
17299         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
17300         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17301         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17302         long ret_ref = (long)ret_var.inner;
17303         if (ret_var.is_owned) {
17304                 ret_ref |= 1;
17305         }
17306         return ret_ref;
17307 }
17308
17309 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
17310         LDKDirectedChannelTransactionParameters this_arg_conv;
17311         this_arg_conv.inner = (void*)(this_arg & (~1));
17312         this_arg_conv.is_owned = false;
17313         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
17314         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17315         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17316         long ret_ref = (long)ret_var.inner;
17317         if (ret_var.is_owned) {
17318                 ret_ref |= 1;
17319         }
17320         return ret_ref;
17321 }
17322
17323 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
17324         LDKDirectedChannelTransactionParameters this_arg_conv;
17325         this_arg_conv.inner = (void*)(this_arg & (~1));
17326         this_arg_conv.is_owned = false;
17327         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
17328         return ret_val;
17329 }
17330
17331 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
17332         LDKDirectedChannelTransactionParameters this_arg_conv;
17333         this_arg_conv.inner = (void*)(this_arg & (~1));
17334         this_arg_conv.is_owned = false;
17335         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
17336         return ret_val;
17337 }
17338
17339 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
17340         LDKDirectedChannelTransactionParameters this_arg_conv;
17341         this_arg_conv.inner = (void*)(this_arg & (~1));
17342         this_arg_conv.is_owned = false;
17343         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
17344         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17345         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17346         long ret_ref = (long)ret_var.inner;
17347         if (ret_var.is_owned) {
17348                 ret_ref |= 1;
17349         }
17350         return ret_ref;
17351 }
17352
17353 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
17354         LDKHolderCommitmentTransaction this_obj_conv;
17355         this_obj_conv.inner = (void*)(this_obj & (~1));
17356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17357         HolderCommitmentTransaction_free(this_obj_conv);
17358 }
17359
17360 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
17361         LDKHolderCommitmentTransaction this_ptr_conv;
17362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17363         this_ptr_conv.is_owned = false;
17364         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17365         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
17366         return ret_arr;
17367 }
17368
17369 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
17370         LDKHolderCommitmentTransaction this_ptr_conv;
17371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17372         this_ptr_conv.is_owned = false;
17373         LDKSignature val_ref;
17374         CHECK(*((uint32_t*)val) == 64);
17375         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17376         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
17377 }
17378
17379 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
17380         LDKHolderCommitmentTransaction this_ptr_conv;
17381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17382         this_ptr_conv.is_owned = false;
17383         LDKCVec_SignatureZ val_constr;
17384         val_constr.datalen = *((uint32_t*)val);
17385         if (val_constr.datalen > 0)
17386                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17387         else
17388                 val_constr.data = NULL;
17389         int8_tArray* val_vals = (int8_tArray*)(val + 4);
17390         for (size_t m = 0; m < val_constr.datalen; m++) {
17391                 int8_tArray val_conv_12 = val_vals[m];
17392                 LDKSignature val_conv_12_ref;
17393                 CHECK(*((uint32_t*)val_conv_12) == 64);
17394                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
17395                 val_constr.data[m] = val_conv_12_ref;
17396         }
17397         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
17398 }
17399
17400 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
17401         LDKHolderCommitmentTransaction orig_conv;
17402         orig_conv.inner = (void*)(orig & (~1));
17403         orig_conv.is_owned = false;
17404         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
17405         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17406         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17407         long ret_ref = (long)ret_var.inner;
17408         if (ret_var.is_owned) {
17409                 ret_ref |= 1;
17410         }
17411         return ret_ref;
17412 }
17413
17414 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
17415         LDKHolderCommitmentTransaction obj_conv;
17416         obj_conv.inner = (void*)(obj & (~1));
17417         obj_conv.is_owned = false;
17418         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
17419         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17420         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17421         CVec_u8Z_free(ret_var);
17422         return ret_arr;
17423 }
17424
17425 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
17426         LDKu8slice ser_ref;
17427         ser_ref.datalen = *((uint32_t*)ser);
17428         ser_ref.data = (int8_t*)(ser + 4);
17429         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
17430         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
17431         return (long)ret_conv;
17432 }
17433
17434 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_new(uint32_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
17435         LDKCommitmentTransaction commitment_tx_conv;
17436         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
17437         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
17438         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
17439         LDKSignature counterparty_sig_ref;
17440         CHECK(*((uint32_t*)counterparty_sig) == 64);
17441         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
17442         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
17443         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
17444         if (counterparty_htlc_sigs_constr.datalen > 0)
17445                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17446         else
17447                 counterparty_htlc_sigs_constr.data = NULL;
17448         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
17449         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
17450                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
17451                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
17452                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
17453                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
17454                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
17455         }
17456         LDKPublicKey holder_funding_key_ref;
17457         CHECK(*((uint32_t*)holder_funding_key) == 33);
17458         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
17459         LDKPublicKey counterparty_funding_key_ref;
17460         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
17461         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
17462         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
17463         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17464         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17465         long ret_ref = (long)ret_var.inner;
17466         if (ret_var.is_owned) {
17467                 ret_ref |= 1;
17468         }
17469         return ret_ref;
17470 }
17471
17472 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
17473         LDKBuiltCommitmentTransaction this_obj_conv;
17474         this_obj_conv.inner = (void*)(this_obj & (~1));
17475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17476         BuiltCommitmentTransaction_free(this_obj_conv);
17477 }
17478
17479 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
17480         LDKBuiltCommitmentTransaction this_ptr_conv;
17481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17482         this_ptr_conv.is_owned = false;
17483         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
17484         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17485         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17486         Transaction_free(ret_var);
17487         return ret_arr;
17488 }
17489
17490 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
17491         LDKBuiltCommitmentTransaction this_ptr_conv;
17492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17493         this_ptr_conv.is_owned = false;
17494         LDKTransaction val_ref;
17495         val_ref.datalen = *((uint32_t*)val);
17496         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
17497         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17498         val_ref.data_is_owned = true;
17499         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
17500 }
17501
17502 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
17503         LDKBuiltCommitmentTransaction this_ptr_conv;
17504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17505         this_ptr_conv.is_owned = false;
17506         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17507         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
17508         return ret_arr;
17509 }
17510
17511 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
17512         LDKBuiltCommitmentTransaction this_ptr_conv;
17513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17514         this_ptr_conv.is_owned = false;
17515         LDKThirtyTwoBytes val_ref;
17516         CHECK(*((uint32_t*)val) == 32);
17517         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17518         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
17519 }
17520
17521 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
17522         LDKTransaction transaction_arg_ref;
17523         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
17524         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
17525         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
17526         transaction_arg_ref.data_is_owned = true;
17527         LDKThirtyTwoBytes txid_arg_ref;
17528         CHECK(*((uint32_t*)txid_arg) == 32);
17529         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
17530         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
17531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17533         long ret_ref = (long)ret_var.inner;
17534         if (ret_var.is_owned) {
17535                 ret_ref |= 1;
17536         }
17537         return ret_ref;
17538 }
17539
17540 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
17541         LDKBuiltCommitmentTransaction orig_conv;
17542         orig_conv.inner = (void*)(orig & (~1));
17543         orig_conv.is_owned = false;
17544         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
17545         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17546         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17547         long ret_ref = (long)ret_var.inner;
17548         if (ret_var.is_owned) {
17549                 ret_ref |= 1;
17550         }
17551         return ret_ref;
17552 }
17553
17554 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
17555         LDKBuiltCommitmentTransaction obj_conv;
17556         obj_conv.inner = (void*)(obj & (~1));
17557         obj_conv.is_owned = false;
17558         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
17559         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17560         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17561         CVec_u8Z_free(ret_var);
17562         return ret_arr;
17563 }
17564
17565 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
17566         LDKu8slice ser_ref;
17567         ser_ref.datalen = *((uint32_t*)ser);
17568         ser_ref.data = (int8_t*)(ser + 4);
17569         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17570         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
17571         return (long)ret_conv;
17572 }
17573
17574 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
17575         LDKBuiltCommitmentTransaction this_arg_conv;
17576         this_arg_conv.inner = (void*)(this_arg & (~1));
17577         this_arg_conv.is_owned = false;
17578         LDKu8slice funding_redeemscript_ref;
17579         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17580         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17581         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17582         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
17583         return ret_arr;
17584 }
17585
17586 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
17587         LDKBuiltCommitmentTransaction this_arg_conv;
17588         this_arg_conv.inner = (void*)(this_arg & (~1));
17589         this_arg_conv.is_owned = false;
17590         unsigned char funding_key_arr[32];
17591         CHECK(*((uint32_t*)funding_key) == 32);
17592         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
17593         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
17594         LDKu8slice funding_redeemscript_ref;
17595         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17596         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17597         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17598         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
17599         return ret_arr;
17600 }
17601
17602 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
17603         LDKCommitmentTransaction this_obj_conv;
17604         this_obj_conv.inner = (void*)(this_obj & (~1));
17605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17606         CommitmentTransaction_free(this_obj_conv);
17607 }
17608
17609 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
17610         LDKCommitmentTransaction orig_conv;
17611         orig_conv.inner = (void*)(orig & (~1));
17612         orig_conv.is_owned = false;
17613         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
17614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17616         long ret_ref = (long)ret_var.inner;
17617         if (ret_var.is_owned) {
17618                 ret_ref |= 1;
17619         }
17620         return ret_ref;
17621 }
17622
17623 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
17624         LDKCommitmentTransaction obj_conv;
17625         obj_conv.inner = (void*)(obj & (~1));
17626         obj_conv.is_owned = false;
17627         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
17628         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17629         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17630         CVec_u8Z_free(ret_var);
17631         return ret_arr;
17632 }
17633
17634 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
17635         LDKu8slice ser_ref;
17636         ser_ref.datalen = *((uint32_t*)ser);
17637         ser_ref.data = (int8_t*)(ser + 4);
17638         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17639         *ret_conv = CommitmentTransaction_read(ser_ref);
17640         return (long)ret_conv;
17641 }
17642
17643 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
17644         LDKCommitmentTransaction this_arg_conv;
17645         this_arg_conv.inner = (void*)(this_arg & (~1));
17646         this_arg_conv.is_owned = false;
17647         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
17648         return ret_val;
17649 }
17650
17651 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
17652         LDKCommitmentTransaction this_arg_conv;
17653         this_arg_conv.inner = (void*)(this_arg & (~1));
17654         this_arg_conv.is_owned = false;
17655         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
17656         return ret_val;
17657 }
17658
17659 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
17660         LDKCommitmentTransaction this_arg_conv;
17661         this_arg_conv.inner = (void*)(this_arg & (~1));
17662         this_arg_conv.is_owned = false;
17663         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
17664         return ret_val;
17665 }
17666
17667 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
17668         LDKCommitmentTransaction this_arg_conv;
17669         this_arg_conv.inner = (void*)(this_arg & (~1));
17670         this_arg_conv.is_owned = false;
17671         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
17672         return ret_val;
17673 }
17674
17675 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
17676         LDKCommitmentTransaction this_arg_conv;
17677         this_arg_conv.inner = (void*)(this_arg & (~1));
17678         this_arg_conv.is_owned = false;
17679         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
17680         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17681         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17682         long ret_ref = (long)ret_var.inner;
17683         if (ret_var.is_owned) {
17684                 ret_ref |= 1;
17685         }
17686         return ret_ref;
17687 }
17688
17689 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
17690         LDKCommitmentTransaction this_arg_conv;
17691         this_arg_conv.inner = (void*)(this_arg & (~1));
17692         this_arg_conv.is_owned = false;
17693         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17694         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17695         channel_parameters_conv.is_owned = false;
17696         LDKChannelPublicKeys broadcaster_keys_conv;
17697         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17698         broadcaster_keys_conv.is_owned = false;
17699         LDKChannelPublicKeys countersignatory_keys_conv;
17700         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17701         countersignatory_keys_conv.is_owned = false;
17702         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17703         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
17704         return (long)ret_conv;
17705 }
17706
17707 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
17708         LDKTrustedCommitmentTransaction this_obj_conv;
17709         this_obj_conv.inner = (void*)(this_obj & (~1));
17710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17711         TrustedCommitmentTransaction_free(this_obj_conv);
17712 }
17713
17714 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
17715         LDKTrustedCommitmentTransaction this_arg_conv;
17716         this_arg_conv.inner = (void*)(this_arg & (~1));
17717         this_arg_conv.is_owned = false;
17718         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17719         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
17720         return ret_arr;
17721 }
17722
17723 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
17724         LDKTrustedCommitmentTransaction this_arg_conv;
17725         this_arg_conv.inner = (void*)(this_arg & (~1));
17726         this_arg_conv.is_owned = false;
17727         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
17728         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17729         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17730         long ret_ref = (long)ret_var.inner;
17731         if (ret_var.is_owned) {
17732                 ret_ref |= 1;
17733         }
17734         return ret_ref;
17735 }
17736
17737 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
17738         LDKTrustedCommitmentTransaction this_arg_conv;
17739         this_arg_conv.inner = (void*)(this_arg & (~1));
17740         this_arg_conv.is_owned = false;
17741         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
17742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17744         long ret_ref = (long)ret_var.inner;
17745         if (ret_var.is_owned) {
17746                 ret_ref |= 1;
17747         }
17748         return ret_ref;
17749 }
17750
17751 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
17752         LDKTrustedCommitmentTransaction this_arg_conv;
17753         this_arg_conv.inner = (void*)(this_arg & (~1));
17754         this_arg_conv.is_owned = false;
17755         unsigned char htlc_base_key_arr[32];
17756         CHECK(*((uint32_t*)htlc_base_key) == 32);
17757         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
17758         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
17759         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17760         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17761         channel_parameters_conv.is_owned = false;
17762         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17763         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
17764         return (long)ret_conv;
17765 }
17766
17767 int64_t  __attribute__((visibility("default"))) TS_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
17768         LDKPublicKey broadcaster_payment_basepoint_ref;
17769         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
17770         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
17771         LDKPublicKey countersignatory_payment_basepoint_ref;
17772         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
17773         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
17774         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
17775         return ret_val;
17776 }
17777
17778 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
17779         LDKInitFeatures orig_conv;
17780         orig_conv.inner = (void*)(orig & (~1));
17781         orig_conv.is_owned = false;
17782         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
17783         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17784         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17785         long ret_ref = (long)ret_var.inner;
17786         if (ret_var.is_owned) {
17787                 ret_ref |= 1;
17788         }
17789         return ret_ref;
17790 }
17791
17792 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
17793         LDKNodeFeatures orig_conv;
17794         orig_conv.inner = (void*)(orig & (~1));
17795         orig_conv.is_owned = false;
17796         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
17797         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17798         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17799         long ret_ref = (long)ret_var.inner;
17800         if (ret_var.is_owned) {
17801                 ret_ref |= 1;
17802         }
17803         return ret_ref;
17804 }
17805
17806 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
17807         LDKChannelFeatures orig_conv;
17808         orig_conv.inner = (void*)(orig & (~1));
17809         orig_conv.is_owned = false;
17810         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
17811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17813         long ret_ref = (long)ret_var.inner;
17814         if (ret_var.is_owned) {
17815                 ret_ref |= 1;
17816         }
17817         return ret_ref;
17818 }
17819
17820 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
17821         LDKInvoiceFeatures orig_conv;
17822         orig_conv.inner = (void*)(orig & (~1));
17823         orig_conv.is_owned = false;
17824         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
17825         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17826         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17827         long ret_ref = (long)ret_var.inner;
17828         if (ret_var.is_owned) {
17829                 ret_ref |= 1;
17830         }
17831         return ret_ref;
17832 }
17833
17834 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
17835         LDKInitFeatures this_obj_conv;
17836         this_obj_conv.inner = (void*)(this_obj & (~1));
17837         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17838         InitFeatures_free(this_obj_conv);
17839 }
17840
17841 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
17842         LDKNodeFeatures this_obj_conv;
17843         this_obj_conv.inner = (void*)(this_obj & (~1));
17844         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17845         NodeFeatures_free(this_obj_conv);
17846 }
17847
17848 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
17849         LDKChannelFeatures this_obj_conv;
17850         this_obj_conv.inner = (void*)(this_obj & (~1));
17851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17852         ChannelFeatures_free(this_obj_conv);
17853 }
17854
17855 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
17856         LDKInvoiceFeatures this_obj_conv;
17857         this_obj_conv.inner = (void*)(this_obj & (~1));
17858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17859         InvoiceFeatures_free(this_obj_conv);
17860 }
17861
17862 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
17863         LDKInitFeatures ret_var = InitFeatures_empty();
17864         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17865         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17866         long ret_ref = (long)ret_var.inner;
17867         if (ret_var.is_owned) {
17868                 ret_ref |= 1;
17869         }
17870         return ret_ref;
17871 }
17872
17873 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
17874         LDKInitFeatures ret_var = InitFeatures_known();
17875         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17876         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17877         long ret_ref = (long)ret_var.inner;
17878         if (ret_var.is_owned) {
17879                 ret_ref |= 1;
17880         }
17881         return ret_ref;
17882 }
17883
17884 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
17885         LDKNodeFeatures ret_var = NodeFeatures_empty();
17886         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17887         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17888         long ret_ref = (long)ret_var.inner;
17889         if (ret_var.is_owned) {
17890                 ret_ref |= 1;
17891         }
17892         return ret_ref;
17893 }
17894
17895 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
17896         LDKNodeFeatures ret_var = NodeFeatures_known();
17897         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17898         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17899         long ret_ref = (long)ret_var.inner;
17900         if (ret_var.is_owned) {
17901                 ret_ref |= 1;
17902         }
17903         return ret_ref;
17904 }
17905
17906 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
17907         LDKChannelFeatures ret_var = ChannelFeatures_empty();
17908         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17909         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17910         long ret_ref = (long)ret_var.inner;
17911         if (ret_var.is_owned) {
17912                 ret_ref |= 1;
17913         }
17914         return ret_ref;
17915 }
17916
17917 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
17918         LDKChannelFeatures ret_var = ChannelFeatures_known();
17919         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17920         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17921         long ret_ref = (long)ret_var.inner;
17922         if (ret_var.is_owned) {
17923                 ret_ref |= 1;
17924         }
17925         return ret_ref;
17926 }
17927
17928 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
17929         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
17930         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17931         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17932         long ret_ref = (long)ret_var.inner;
17933         if (ret_var.is_owned) {
17934                 ret_ref |= 1;
17935         }
17936         return ret_ref;
17937 }
17938
17939 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
17940         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
17941         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17942         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17943         long ret_ref = (long)ret_var.inner;
17944         if (ret_var.is_owned) {
17945                 ret_ref |= 1;
17946         }
17947         return ret_ref;
17948 }
17949
17950 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
17951         LDKInitFeatures obj_conv;
17952         obj_conv.inner = (void*)(obj & (~1));
17953         obj_conv.is_owned = false;
17954         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
17955         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17956         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17957         CVec_u8Z_free(ret_var);
17958         return ret_arr;
17959 }
17960
17961 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
17962         LDKNodeFeatures obj_conv;
17963         obj_conv.inner = (void*)(obj & (~1));
17964         obj_conv.is_owned = false;
17965         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
17966         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17967         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17968         CVec_u8Z_free(ret_var);
17969         return ret_arr;
17970 }
17971
17972 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
17973         LDKChannelFeatures obj_conv;
17974         obj_conv.inner = (void*)(obj & (~1));
17975         obj_conv.is_owned = false;
17976         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
17977         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17978         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17979         CVec_u8Z_free(ret_var);
17980         return ret_arr;
17981 }
17982
17983 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
17984         LDKInvoiceFeatures obj_conv;
17985         obj_conv.inner = (void*)(obj & (~1));
17986         obj_conv.is_owned = false;
17987         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
17988         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17989         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17990         CVec_u8Z_free(ret_var);
17991         return ret_arr;
17992 }
17993
17994 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
17995         LDKu8slice ser_ref;
17996         ser_ref.datalen = *((uint32_t*)ser);
17997         ser_ref.data = (int8_t*)(ser + 4);
17998         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17999         *ret_conv = InitFeatures_read(ser_ref);
18000         return (long)ret_conv;
18001 }
18002
18003 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
18004         LDKu8slice ser_ref;
18005         ser_ref.datalen = *((uint32_t*)ser);
18006         ser_ref.data = (int8_t*)(ser + 4);
18007         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18008         *ret_conv = NodeFeatures_read(ser_ref);
18009         return (long)ret_conv;
18010 }
18011
18012 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
18013         LDKu8slice ser_ref;
18014         ser_ref.datalen = *((uint32_t*)ser);
18015         ser_ref.data = (int8_t*)(ser + 4);
18016         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18017         *ret_conv = ChannelFeatures_read(ser_ref);
18018         return (long)ret_conv;
18019 }
18020
18021 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
18022         LDKu8slice ser_ref;
18023         ser_ref.datalen = *((uint32_t*)ser);
18024         ser_ref.data = (int8_t*)(ser + 4);
18025         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18026         *ret_conv = InvoiceFeatures_read(ser_ref);
18027         return (long)ret_conv;
18028 }
18029
18030 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
18031         LDKRouteHop this_obj_conv;
18032         this_obj_conv.inner = (void*)(this_obj & (~1));
18033         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18034         RouteHop_free(this_obj_conv);
18035 }
18036
18037 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
18038         LDKRouteHop this_ptr_conv;
18039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18040         this_ptr_conv.is_owned = false;
18041         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18042         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
18043         return ret_arr;
18044 }
18045
18046 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
18047         LDKRouteHop this_ptr_conv;
18048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18049         this_ptr_conv.is_owned = false;
18050         LDKPublicKey val_ref;
18051         CHECK(*((uint32_t*)val) == 33);
18052         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18053         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
18054 }
18055
18056 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
18057         LDKRouteHop this_ptr_conv;
18058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18059         this_ptr_conv.is_owned = false;
18060         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
18061         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18062         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18063         long ret_ref = (long)ret_var.inner;
18064         if (ret_var.is_owned) {
18065                 ret_ref |= 1;
18066         }
18067         return ret_ref;
18068 }
18069
18070 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
18071         LDKRouteHop this_ptr_conv;
18072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18073         this_ptr_conv.is_owned = false;
18074         LDKNodeFeatures val_conv;
18075         val_conv.inner = (void*)(val & (~1));
18076         val_conv.is_owned = (val & 1) || (val == 0);
18077         val_conv = NodeFeatures_clone(&val_conv);
18078         RouteHop_set_node_features(&this_ptr_conv, val_conv);
18079 }
18080
18081 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
18082         LDKRouteHop this_ptr_conv;
18083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18084         this_ptr_conv.is_owned = false;
18085         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
18086         return ret_val;
18087 }
18088
18089 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18090         LDKRouteHop this_ptr_conv;
18091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18092         this_ptr_conv.is_owned = false;
18093         RouteHop_set_short_channel_id(&this_ptr_conv, val);
18094 }
18095
18096 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
18097         LDKRouteHop this_ptr_conv;
18098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18099         this_ptr_conv.is_owned = false;
18100         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
18101         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18102         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18103         long ret_ref = (long)ret_var.inner;
18104         if (ret_var.is_owned) {
18105                 ret_ref |= 1;
18106         }
18107         return ret_ref;
18108 }
18109
18110 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
18111         LDKRouteHop this_ptr_conv;
18112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18113         this_ptr_conv.is_owned = false;
18114         LDKChannelFeatures val_conv;
18115         val_conv.inner = (void*)(val & (~1));
18116         val_conv.is_owned = (val & 1) || (val == 0);
18117         val_conv = ChannelFeatures_clone(&val_conv);
18118         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
18119 }
18120
18121 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
18122         LDKRouteHop this_ptr_conv;
18123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18124         this_ptr_conv.is_owned = false;
18125         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
18126         return ret_val;
18127 }
18128
18129 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
18130         LDKRouteHop this_ptr_conv;
18131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18132         this_ptr_conv.is_owned = false;
18133         RouteHop_set_fee_msat(&this_ptr_conv, val);
18134 }
18135
18136 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
18137         LDKRouteHop this_ptr_conv;
18138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18139         this_ptr_conv.is_owned = false;
18140         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
18141         return ret_val;
18142 }
18143
18144 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
18145         LDKRouteHop this_ptr_conv;
18146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18147         this_ptr_conv.is_owned = false;
18148         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
18149 }
18150
18151 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_new(int8_tArray pubkey_arg, uint32_t node_features_arg, int64_t short_channel_id_arg, uint32_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
18152         LDKPublicKey pubkey_arg_ref;
18153         CHECK(*((uint32_t*)pubkey_arg) == 33);
18154         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
18155         LDKNodeFeatures node_features_arg_conv;
18156         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
18157         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
18158         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
18159         LDKChannelFeatures channel_features_arg_conv;
18160         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
18161         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
18162         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
18163         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);
18164         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18165         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18166         long ret_ref = (long)ret_var.inner;
18167         if (ret_var.is_owned) {
18168                 ret_ref |= 1;
18169         }
18170         return ret_ref;
18171 }
18172
18173 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
18174         LDKRouteHop orig_conv;
18175         orig_conv.inner = (void*)(orig & (~1));
18176         orig_conv.is_owned = false;
18177         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
18178         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18179         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18180         long ret_ref = (long)ret_var.inner;
18181         if (ret_var.is_owned) {
18182                 ret_ref |= 1;
18183         }
18184         return ret_ref;
18185 }
18186
18187 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
18188         LDKRoute this_obj_conv;
18189         this_obj_conv.inner = (void*)(this_obj & (~1));
18190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18191         Route_free(this_obj_conv);
18192 }
18193
18194 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
18195         LDKRoute this_ptr_conv;
18196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18197         this_ptr_conv.is_owned = false;
18198         LDKCVec_CVec_RouteHopZZ val_constr;
18199         val_constr.datalen = *((uint32_t*)val);
18200         if (val_constr.datalen > 0)
18201                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18202         else
18203                 val_constr.data = NULL;
18204         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
18205         for (size_t m = 0; m < val_constr.datalen; m++) {
18206                 uint32_tArray val_conv_12 = val_vals[m];
18207                 LDKCVec_RouteHopZ val_conv_12_constr;
18208                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
18209                 if (val_conv_12_constr.datalen > 0)
18210                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18211                 else
18212                         val_conv_12_constr.data = NULL;
18213                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
18214                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
18215                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
18216                         LDKRouteHop val_conv_12_conv_10_conv;
18217                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
18218                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
18219                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
18220                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
18221                 }
18222                 val_constr.data[m] = val_conv_12_constr;
18223         }
18224         Route_set_paths(&this_ptr_conv, val_constr);
18225 }
18226
18227 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
18228         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
18229         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
18230         if (paths_arg_constr.datalen > 0)
18231                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18232         else
18233                 paths_arg_constr.data = NULL;
18234         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
18235         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
18236                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
18237                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
18238                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
18239                 if (paths_arg_conv_12_constr.datalen > 0)
18240                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18241                 else
18242                         paths_arg_conv_12_constr.data = NULL;
18243                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
18244                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
18245                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
18246                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
18247                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
18248                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
18249                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
18250                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
18251                 }
18252                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
18253         }
18254         LDKRoute ret_var = Route_new(paths_arg_constr);
18255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18257         long ret_ref = (long)ret_var.inner;
18258         if (ret_var.is_owned) {
18259                 ret_ref |= 1;
18260         }
18261         return ret_ref;
18262 }
18263
18264 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
18265         LDKRoute orig_conv;
18266         orig_conv.inner = (void*)(orig & (~1));
18267         orig_conv.is_owned = false;
18268         LDKRoute ret_var = Route_clone(&orig_conv);
18269         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18270         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18271         long ret_ref = (long)ret_var.inner;
18272         if (ret_var.is_owned) {
18273                 ret_ref |= 1;
18274         }
18275         return ret_ref;
18276 }
18277
18278 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
18279         LDKRoute obj_conv;
18280         obj_conv.inner = (void*)(obj & (~1));
18281         obj_conv.is_owned = false;
18282         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
18283         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18284         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18285         CVec_u8Z_free(ret_var);
18286         return ret_arr;
18287 }
18288
18289 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
18290         LDKu8slice ser_ref;
18291         ser_ref.datalen = *((uint32_t*)ser);
18292         ser_ref.data = (int8_t*)(ser + 4);
18293         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18294         *ret_conv = Route_read(ser_ref);
18295         return (long)ret_conv;
18296 }
18297
18298 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
18299         LDKRouteHint this_obj_conv;
18300         this_obj_conv.inner = (void*)(this_obj & (~1));
18301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18302         RouteHint_free(this_obj_conv);
18303 }
18304
18305 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
18306         LDKRouteHint this_ptr_conv;
18307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18308         this_ptr_conv.is_owned = false;
18309         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18310         memcpy((uint8_t*)(ret_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
18311         return ret_arr;
18312 }
18313
18314 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
18315         LDKRouteHint this_ptr_conv;
18316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18317         this_ptr_conv.is_owned = false;
18318         LDKPublicKey val_ref;
18319         CHECK(*((uint32_t*)val) == 33);
18320         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18321         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
18322 }
18323
18324 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
18325         LDKRouteHint this_ptr_conv;
18326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18327         this_ptr_conv.is_owned = false;
18328         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
18329         return ret_val;
18330 }
18331
18332 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18333         LDKRouteHint this_ptr_conv;
18334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18335         this_ptr_conv.is_owned = false;
18336         RouteHint_set_short_channel_id(&this_ptr_conv, val);
18337 }
18338
18339 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
18340         LDKRouteHint this_ptr_conv;
18341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18342         this_ptr_conv.is_owned = false;
18343         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
18344         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18345         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18346         long ret_ref = (long)ret_var.inner;
18347         if (ret_var.is_owned) {
18348                 ret_ref |= 1;
18349         }
18350         return ret_ref;
18351 }
18352
18353 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
18354         LDKRouteHint this_ptr_conv;
18355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18356         this_ptr_conv.is_owned = false;
18357         LDKRoutingFees val_conv;
18358         val_conv.inner = (void*)(val & (~1));
18359         val_conv.is_owned = (val & 1) || (val == 0);
18360         val_conv = RoutingFees_clone(&val_conv);
18361         RouteHint_set_fees(&this_ptr_conv, val_conv);
18362 }
18363
18364 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
18365         LDKRouteHint this_ptr_conv;
18366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18367         this_ptr_conv.is_owned = false;
18368         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
18369         return ret_val;
18370 }
18371
18372 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18373         LDKRouteHint this_ptr_conv;
18374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18375         this_ptr_conv.is_owned = false;
18376         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
18377 }
18378
18379 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_minimum_msat(uint32_t this_ptr) {
18380         LDKRouteHint this_ptr_conv;
18381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18382         this_ptr_conv.is_owned = false;
18383         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18384         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
18385         long ret_ref = (long)ret_copy;
18386         return ret_ref;
18387 }
18388
18389 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
18390         LDKRouteHint this_ptr_conv;
18391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18392         this_ptr_conv.is_owned = false;
18393         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18394         FREE((void*)val);
18395         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
18396 }
18397
18398 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_maximum_msat(uint32_t this_ptr) {
18399         LDKRouteHint this_ptr_conv;
18400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18401         this_ptr_conv.is_owned = false;
18402         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18403         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
18404         long ret_ref = (long)ret_copy;
18405         return ret_ref;
18406 }
18407
18408 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
18409         LDKRouteHint this_ptr_conv;
18410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18411         this_ptr_conv.is_owned = false;
18412         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18413         FREE((void*)val);
18414         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
18415 }
18416
18417 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, int16_t cltv_expiry_delta_arg, uint32_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg) {
18418         LDKPublicKey src_node_id_arg_ref;
18419         CHECK(*((uint32_t*)src_node_id_arg) == 33);
18420         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
18421         LDKRoutingFees fees_arg_conv;
18422         fees_arg_conv.inner = (void*)(fees_arg & (~1));
18423         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
18424         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
18425         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
18426         FREE((void*)htlc_minimum_msat_arg);
18427         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
18428         FREE((void*)htlc_maximum_msat_arg);
18429         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);
18430         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18431         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18432         long ret_ref = (long)ret_var.inner;
18433         if (ret_var.is_owned) {
18434                 ret_ref |= 1;
18435         }
18436         return ret_ref;
18437 }
18438
18439 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
18440         LDKRouteHint orig_conv;
18441         orig_conv.inner = (void*)(orig & (~1));
18442         orig_conv.is_owned = false;
18443         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
18444         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18445         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18446         long ret_ref = (long)ret_var.inner;
18447         if (ret_var.is_owned) {
18448                 ret_ref |= 1;
18449         }
18450         return ret_ref;
18451 }
18452
18453 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
18454         LDKPublicKey our_node_id_ref;
18455         CHECK(*((uint32_t*)our_node_id) == 33);
18456         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
18457         LDKNetworkGraph network_conv;
18458         network_conv.inner = (void*)(network & (~1));
18459         network_conv.is_owned = false;
18460         LDKPublicKey payee_ref;
18461         CHECK(*((uint32_t*)payee) == 33);
18462         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
18463         LDKInvoiceFeatures payee_features_conv;
18464         payee_features_conv.inner = (void*)(payee_features & (~1));
18465         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
18466         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
18467         LDKCVec_ChannelDetailsZ first_hops_constr;
18468         first_hops_constr.datalen = *((uint32_t*)first_hops);
18469         if (first_hops_constr.datalen > 0)
18470                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18471         else
18472                 first_hops_constr.data = NULL;
18473         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
18474         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
18475                 uint32_t first_hops_conv_16 = first_hops_vals[q];
18476                 LDKChannelDetails first_hops_conv_16_conv;
18477                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
18478                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
18479                 first_hops_constr.data[q] = first_hops_conv_16_conv;
18480         }
18481         LDKCVec_RouteHintZ last_hops_constr;
18482         last_hops_constr.datalen = *((uint32_t*)last_hops);
18483         if (last_hops_constr.datalen > 0)
18484                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18485         else
18486                 last_hops_constr.data = NULL;
18487         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
18488         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
18489                 uint32_t last_hops_conv_11 = last_hops_vals[l];
18490                 LDKRouteHint last_hops_conv_11_conv;
18491                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
18492                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
18493                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
18494                 last_hops_constr.data[l] = last_hops_conv_11_conv;
18495         }
18496         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18497         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
18498         *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);
18499         FREE(first_hops_constr.data);
18500         return (long)ret_conv;
18501 }
18502
18503 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
18504         LDKNetworkGraph this_obj_conv;
18505         this_obj_conv.inner = (void*)(this_obj & (~1));
18506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18507         NetworkGraph_free(this_obj_conv);
18508 }
18509
18510 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
18511         LDKNetworkGraph orig_conv;
18512         orig_conv.inner = (void*)(orig & (~1));
18513         orig_conv.is_owned = false;
18514         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
18515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18517         long ret_ref = (long)ret_var.inner;
18518         if (ret_var.is_owned) {
18519                 ret_ref |= 1;
18520         }
18521         return ret_ref;
18522 }
18523
18524 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
18525         LDKLockedNetworkGraph this_obj_conv;
18526         this_obj_conv.inner = (void*)(this_obj & (~1));
18527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18528         LockedNetworkGraph_free(this_obj_conv);
18529 }
18530
18531 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
18532         LDKNetGraphMsgHandler this_obj_conv;
18533         this_obj_conv.inner = (void*)(this_obj & (~1));
18534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18535         NetGraphMsgHandler_free(this_obj_conv);
18536 }
18537
18538 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
18539         LDKThirtyTwoBytes genesis_hash_ref;
18540         CHECK(*((uint32_t*)genesis_hash) == 32);
18541         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
18542         LDKAccess *chain_access_conv_ptr = NULL;
18543         if (chain_access != 0) {
18544                 LDKAccess chain_access_conv;
18545                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18546                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18547                 *chain_access_conv_ptr = chain_access_conv;
18548         }
18549         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18550         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
18551         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18552         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18553         long ret_ref = (long)ret_var.inner;
18554         if (ret_var.is_owned) {
18555                 ret_ref |= 1;
18556         }
18557         return ret_ref;
18558 }
18559
18560 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
18561         LDKAccess *chain_access_conv_ptr = NULL;
18562         if (chain_access != 0) {
18563                 LDKAccess chain_access_conv;
18564                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18565                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18566                 *chain_access_conv_ptr = chain_access_conv;
18567         }
18568         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18569         LDKNetworkGraph network_graph_conv;
18570         network_graph_conv.inner = (void*)(network_graph & (~1));
18571         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
18572         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
18573         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
18574         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18575         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18576         long ret_ref = (long)ret_var.inner;
18577         if (ret_var.is_owned) {
18578                 ret_ref |= 1;
18579         }
18580         return ret_ref;
18581 }
18582
18583 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
18584         LDKNetGraphMsgHandler this_arg_conv;
18585         this_arg_conv.inner = (void*)(this_arg & (~1));
18586         this_arg_conv.is_owned = false;
18587         LDKAccess *chain_access_conv_ptr = NULL;
18588         if (chain_access != 0) {
18589                 LDKAccess chain_access_conv;
18590                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18591                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18592                 *chain_access_conv_ptr = chain_access_conv;
18593         }
18594         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
18595 }
18596
18597 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
18598         LDKNetGraphMsgHandler this_arg_conv;
18599         this_arg_conv.inner = (void*)(this_arg & (~1));
18600         this_arg_conv.is_owned = false;
18601         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
18602         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18603         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18604         long ret_ref = (long)ret_var.inner;
18605         if (ret_var.is_owned) {
18606                 ret_ref |= 1;
18607         }
18608         return ret_ref;
18609 }
18610
18611 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
18612         LDKLockedNetworkGraph this_arg_conv;
18613         this_arg_conv.inner = (void*)(this_arg & (~1));
18614         this_arg_conv.is_owned = false;
18615         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
18616         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18617         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18618         long ret_ref = (long)ret_var.inner;
18619         if (ret_var.is_owned) {
18620                 ret_ref |= 1;
18621         }
18622         return ret_ref;
18623 }
18624
18625 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18626         LDKNetGraphMsgHandler this_arg_conv;
18627         this_arg_conv.inner = (void*)(this_arg & (~1));
18628         this_arg_conv.is_owned = false;
18629         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18630         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
18631         return (long)ret;
18632 }
18633
18634 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18635         LDKNetGraphMsgHandler this_arg_conv;
18636         this_arg_conv.inner = (void*)(this_arg & (~1));
18637         this_arg_conv.is_owned = false;
18638         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18639         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
18640         return (long)ret;
18641 }
18642
18643 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
18644         LDKDirectionalChannelInfo this_obj_conv;
18645         this_obj_conv.inner = (void*)(this_obj & (~1));
18646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18647         DirectionalChannelInfo_free(this_obj_conv);
18648 }
18649
18650 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
18651         LDKDirectionalChannelInfo this_ptr_conv;
18652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18653         this_ptr_conv.is_owned = false;
18654         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
18655         return ret_val;
18656 }
18657
18658 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
18659         LDKDirectionalChannelInfo this_ptr_conv;
18660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18661         this_ptr_conv.is_owned = false;
18662         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
18663 }
18664
18665 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
18666         LDKDirectionalChannelInfo this_ptr_conv;
18667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18668         this_ptr_conv.is_owned = false;
18669         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
18670         return ret_val;
18671 }
18672
18673 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
18674         LDKDirectionalChannelInfo this_ptr_conv;
18675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18676         this_ptr_conv.is_owned = false;
18677         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
18678 }
18679
18680 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
18681         LDKDirectionalChannelInfo this_ptr_conv;
18682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18683         this_ptr_conv.is_owned = false;
18684         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
18685         return ret_val;
18686 }
18687
18688 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18689         LDKDirectionalChannelInfo this_ptr_conv;
18690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18691         this_ptr_conv.is_owned = false;
18692         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18693 }
18694
18695 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
18696         LDKDirectionalChannelInfo this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
18700         return ret_val;
18701 }
18702
18703 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
18704         LDKDirectionalChannelInfo this_ptr_conv;
18705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18706         this_ptr_conv.is_owned = false;
18707         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
18708 }
18709
18710 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
18711         LDKDirectionalChannelInfo this_ptr_conv;
18712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18713         this_ptr_conv.is_owned = false;
18714         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18715         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
18716         long ret_ref = (long)ret_copy;
18717         return ret_ref;
18718 }
18719
18720 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
18721         LDKDirectionalChannelInfo this_ptr_conv;
18722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18723         this_ptr_conv.is_owned = false;
18724         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18725         FREE((void*)val);
18726         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
18727 }
18728
18729 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
18730         LDKDirectionalChannelInfo this_ptr_conv;
18731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18732         this_ptr_conv.is_owned = false;
18733         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
18734         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18735         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18736         long ret_ref = (long)ret_var.inner;
18737         if (ret_var.is_owned) {
18738                 ret_ref |= 1;
18739         }
18740         return ret_ref;
18741 }
18742
18743 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
18744         LDKDirectionalChannelInfo this_ptr_conv;
18745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18746         this_ptr_conv.is_owned = false;
18747         LDKRoutingFees val_conv;
18748         val_conv.inner = (void*)(val & (~1));
18749         val_conv.is_owned = (val & 1) || (val == 0);
18750         val_conv = RoutingFees_clone(&val_conv);
18751         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
18752 }
18753
18754 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
18755         LDKDirectionalChannelInfo this_ptr_conv;
18756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18757         this_ptr_conv.is_owned = false;
18758         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
18759         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18760         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18761         long ret_ref = (long)ret_var.inner;
18762         if (ret_var.is_owned) {
18763                 ret_ref |= 1;
18764         }
18765         return ret_ref;
18766 }
18767
18768 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
18769         LDKDirectionalChannelInfo this_ptr_conv;
18770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18771         this_ptr_conv.is_owned = false;
18772         LDKChannelUpdate val_conv;
18773         val_conv.inner = (void*)(val & (~1));
18774         val_conv.is_owned = (val & 1) || (val == 0);
18775         val_conv = ChannelUpdate_clone(&val_conv);
18776         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
18777 }
18778
18779 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
18780         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
18781         FREE((void*)htlc_maximum_msat_arg);
18782         LDKRoutingFees fees_arg_conv;
18783         fees_arg_conv.inner = (void*)(fees_arg & (~1));
18784         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
18785         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
18786         LDKChannelUpdate last_update_message_arg_conv;
18787         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
18788         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
18789         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
18790         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);
18791         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18792         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18793         long ret_ref = (long)ret_var.inner;
18794         if (ret_var.is_owned) {
18795                 ret_ref |= 1;
18796         }
18797         return ret_ref;
18798 }
18799
18800 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
18801         LDKDirectionalChannelInfo orig_conv;
18802         orig_conv.inner = (void*)(orig & (~1));
18803         orig_conv.is_owned = false;
18804         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
18805         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18806         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18807         long ret_ref = (long)ret_var.inner;
18808         if (ret_var.is_owned) {
18809                 ret_ref |= 1;
18810         }
18811         return ret_ref;
18812 }
18813
18814 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
18815         LDKDirectionalChannelInfo obj_conv;
18816         obj_conv.inner = (void*)(obj & (~1));
18817         obj_conv.is_owned = false;
18818         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
18819         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18820         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18821         CVec_u8Z_free(ret_var);
18822         return ret_arr;
18823 }
18824
18825 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
18826         LDKu8slice ser_ref;
18827         ser_ref.datalen = *((uint32_t*)ser);
18828         ser_ref.data = (int8_t*)(ser + 4);
18829         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
18830         *ret_conv = DirectionalChannelInfo_read(ser_ref);
18831         return (long)ret_conv;
18832 }
18833
18834 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
18835         LDKChannelInfo this_obj_conv;
18836         this_obj_conv.inner = (void*)(this_obj & (~1));
18837         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18838         ChannelInfo_free(this_obj_conv);
18839 }
18840
18841 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
18842         LDKChannelInfo this_ptr_conv;
18843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18844         this_ptr_conv.is_owned = false;
18845         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
18846         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18847         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18848         long ret_ref = (long)ret_var.inner;
18849         if (ret_var.is_owned) {
18850                 ret_ref |= 1;
18851         }
18852         return ret_ref;
18853 }
18854
18855 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
18856         LDKChannelInfo this_ptr_conv;
18857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18858         this_ptr_conv.is_owned = false;
18859         LDKChannelFeatures val_conv;
18860         val_conv.inner = (void*)(val & (~1));
18861         val_conv.is_owned = (val & 1) || (val == 0);
18862         val_conv = ChannelFeatures_clone(&val_conv);
18863         ChannelInfo_set_features(&this_ptr_conv, val_conv);
18864 }
18865
18866 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
18867         LDKChannelInfo this_ptr_conv;
18868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18869         this_ptr_conv.is_owned = false;
18870         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18871         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
18872         return ret_arr;
18873 }
18874
18875 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
18876         LDKChannelInfo this_ptr_conv;
18877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18878         this_ptr_conv.is_owned = false;
18879         LDKPublicKey val_ref;
18880         CHECK(*((uint32_t*)val) == 33);
18881         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18882         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
18883 }
18884
18885 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
18886         LDKChannelInfo this_ptr_conv;
18887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18888         this_ptr_conv.is_owned = false;
18889         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
18890         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18891         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18892         long ret_ref = (long)ret_var.inner;
18893         if (ret_var.is_owned) {
18894                 ret_ref |= 1;
18895         }
18896         return ret_ref;
18897 }
18898
18899 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
18900         LDKChannelInfo this_ptr_conv;
18901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18902         this_ptr_conv.is_owned = false;
18903         LDKDirectionalChannelInfo val_conv;
18904         val_conv.inner = (void*)(val & (~1));
18905         val_conv.is_owned = (val & 1) || (val == 0);
18906         val_conv = DirectionalChannelInfo_clone(&val_conv);
18907         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
18908 }
18909
18910 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
18911         LDKChannelInfo this_ptr_conv;
18912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18913         this_ptr_conv.is_owned = false;
18914         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18915         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
18916         return ret_arr;
18917 }
18918
18919 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
18920         LDKChannelInfo this_ptr_conv;
18921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18922         this_ptr_conv.is_owned = false;
18923         LDKPublicKey val_ref;
18924         CHECK(*((uint32_t*)val) == 33);
18925         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18926         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
18927 }
18928
18929 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
18930         LDKChannelInfo this_ptr_conv;
18931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18932         this_ptr_conv.is_owned = false;
18933         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
18934         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18935         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18936         long ret_ref = (long)ret_var.inner;
18937         if (ret_var.is_owned) {
18938                 ret_ref |= 1;
18939         }
18940         return ret_ref;
18941 }
18942
18943 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
18944         LDKChannelInfo this_ptr_conv;
18945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18946         this_ptr_conv.is_owned = false;
18947         LDKDirectionalChannelInfo val_conv;
18948         val_conv.inner = (void*)(val & (~1));
18949         val_conv.is_owned = (val & 1) || (val == 0);
18950         val_conv = DirectionalChannelInfo_clone(&val_conv);
18951         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
18952 }
18953
18954 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
18955         LDKChannelInfo this_ptr_conv;
18956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18957         this_ptr_conv.is_owned = false;
18958         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18959         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
18960         long ret_ref = (long)ret_copy;
18961         return ret_ref;
18962 }
18963
18964 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
18965         LDKChannelInfo this_ptr_conv;
18966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18967         this_ptr_conv.is_owned = false;
18968         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18969         FREE((void*)val);
18970         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
18971 }
18972
18973 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
18974         LDKChannelInfo this_ptr_conv;
18975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18976         this_ptr_conv.is_owned = false;
18977         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
18978         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18979         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18980         long ret_ref = (long)ret_var.inner;
18981         if (ret_var.is_owned) {
18982                 ret_ref |= 1;
18983         }
18984         return ret_ref;
18985 }
18986
18987 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
18988         LDKChannelInfo this_ptr_conv;
18989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18990         this_ptr_conv.is_owned = false;
18991         LDKChannelAnnouncement val_conv;
18992         val_conv.inner = (void*)(val & (~1));
18993         val_conv.is_owned = (val & 1) || (val == 0);
18994         val_conv = ChannelAnnouncement_clone(&val_conv);
18995         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
18996 }
18997
18998 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, int8_tArray node_one_arg, uint32_t one_to_two_arg, int8_tArray node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
18999         LDKChannelFeatures features_arg_conv;
19000         features_arg_conv.inner = (void*)(features_arg & (~1));
19001         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19002         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
19003         LDKPublicKey node_one_arg_ref;
19004         CHECK(*((uint32_t*)node_one_arg) == 33);
19005         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
19006         LDKDirectionalChannelInfo one_to_two_arg_conv;
19007         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
19008         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
19009         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
19010         LDKPublicKey node_two_arg_ref;
19011         CHECK(*((uint32_t*)node_two_arg) == 33);
19012         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
19013         LDKDirectionalChannelInfo two_to_one_arg_conv;
19014         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
19015         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
19016         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
19017         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
19018         FREE((void*)capacity_sats_arg);
19019         LDKChannelAnnouncement announcement_message_arg_conv;
19020         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19021         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19022         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
19023         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);
19024         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19025         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19026         long ret_ref = (long)ret_var.inner;
19027         if (ret_var.is_owned) {
19028                 ret_ref |= 1;
19029         }
19030         return ret_ref;
19031 }
19032
19033 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
19034         LDKChannelInfo orig_conv;
19035         orig_conv.inner = (void*)(orig & (~1));
19036         orig_conv.is_owned = false;
19037         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
19038         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19039         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19040         long ret_ref = (long)ret_var.inner;
19041         if (ret_var.is_owned) {
19042                 ret_ref |= 1;
19043         }
19044         return ret_ref;
19045 }
19046
19047 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
19048         LDKChannelInfo obj_conv;
19049         obj_conv.inner = (void*)(obj & (~1));
19050         obj_conv.is_owned = false;
19051         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
19052         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19053         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19054         CVec_u8Z_free(ret_var);
19055         return ret_arr;
19056 }
19057
19058 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
19059         LDKu8slice ser_ref;
19060         ser_ref.datalen = *((uint32_t*)ser);
19061         ser_ref.data = (int8_t*)(ser + 4);
19062         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19063         *ret_conv = ChannelInfo_read(ser_ref);
19064         return (long)ret_conv;
19065 }
19066
19067 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
19068         LDKRoutingFees this_obj_conv;
19069         this_obj_conv.inner = (void*)(this_obj & (~1));
19070         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19071         RoutingFees_free(this_obj_conv);
19072 }
19073
19074 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
19075         LDKRoutingFees this_ptr_conv;
19076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19077         this_ptr_conv.is_owned = false;
19078         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
19079         return ret_val;
19080 }
19081
19082 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
19083         LDKRoutingFees this_ptr_conv;
19084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19085         this_ptr_conv.is_owned = false;
19086         RoutingFees_set_base_msat(&this_ptr_conv, val);
19087 }
19088
19089 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
19090         LDKRoutingFees this_ptr_conv;
19091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19092         this_ptr_conv.is_owned = false;
19093         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
19094         return ret_val;
19095 }
19096
19097 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
19098         LDKRoutingFees this_ptr_conv;
19099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19100         this_ptr_conv.is_owned = false;
19101         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
19102 }
19103
19104 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
19105         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
19106         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19107         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19108         long ret_ref = (long)ret_var.inner;
19109         if (ret_var.is_owned) {
19110                 ret_ref |= 1;
19111         }
19112         return ret_ref;
19113 }
19114
19115 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
19116         LDKRoutingFees orig_conv;
19117         orig_conv.inner = (void*)(orig & (~1));
19118         orig_conv.is_owned = false;
19119         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
19120         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19121         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19122         long ret_ref = (long)ret_var.inner;
19123         if (ret_var.is_owned) {
19124                 ret_ref |= 1;
19125         }
19126         return ret_ref;
19127 }
19128
19129 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
19130         LDKu8slice ser_ref;
19131         ser_ref.datalen = *((uint32_t*)ser);
19132         ser_ref.data = (int8_t*)(ser + 4);
19133         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19134         *ret_conv = RoutingFees_read(ser_ref);
19135         return (long)ret_conv;
19136 }
19137
19138 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
19139         LDKRoutingFees obj_conv;
19140         obj_conv.inner = (void*)(obj & (~1));
19141         obj_conv.is_owned = false;
19142         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
19143         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19144         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19145         CVec_u8Z_free(ret_var);
19146         return ret_arr;
19147 }
19148
19149 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
19150         LDKNodeAnnouncementInfo this_obj_conv;
19151         this_obj_conv.inner = (void*)(this_obj & (~1));
19152         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19153         NodeAnnouncementInfo_free(this_obj_conv);
19154 }
19155
19156 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
19157         LDKNodeAnnouncementInfo this_ptr_conv;
19158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19159         this_ptr_conv.is_owned = false;
19160         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
19161         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19162         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19163         long ret_ref = (long)ret_var.inner;
19164         if (ret_var.is_owned) {
19165                 ret_ref |= 1;
19166         }
19167         return ret_ref;
19168 }
19169
19170 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
19171         LDKNodeAnnouncementInfo this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         LDKNodeFeatures val_conv;
19175         val_conv.inner = (void*)(val & (~1));
19176         val_conv.is_owned = (val & 1) || (val == 0);
19177         val_conv = NodeFeatures_clone(&val_conv);
19178         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
19179 }
19180
19181 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
19182         LDKNodeAnnouncementInfo this_ptr_conv;
19183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19184         this_ptr_conv.is_owned = false;
19185         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
19186         return ret_val;
19187 }
19188
19189 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
19190         LDKNodeAnnouncementInfo this_ptr_conv;
19191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19192         this_ptr_conv.is_owned = false;
19193         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
19194 }
19195
19196 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
19197         LDKNodeAnnouncementInfo this_ptr_conv;
19198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19199         this_ptr_conv.is_owned = false;
19200         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
19201         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
19202         return ret_arr;
19203 }
19204
19205 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
19206         LDKNodeAnnouncementInfo this_ptr_conv;
19207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19208         this_ptr_conv.is_owned = false;
19209         LDKThreeBytes val_ref;
19210         CHECK(*((uint32_t*)val) == 3);
19211         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
19212         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
19213 }
19214
19215 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
19216         LDKNodeAnnouncementInfo this_ptr_conv;
19217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19218         this_ptr_conv.is_owned = false;
19219         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19220         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
19221         return ret_arr;
19222 }
19223
19224 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
19225         LDKNodeAnnouncementInfo this_ptr_conv;
19226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19227         this_ptr_conv.is_owned = false;
19228         LDKThirtyTwoBytes val_ref;
19229         CHECK(*((uint32_t*)val) == 32);
19230         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19231         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
19232 }
19233
19234 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
19235         LDKNodeAnnouncementInfo this_ptr_conv;
19236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19237         this_ptr_conv.is_owned = false;
19238         LDKCVec_NetAddressZ val_constr;
19239         val_constr.datalen = *((uint32_t*)val);
19240         if (val_constr.datalen > 0)
19241                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19242         else
19243                 val_constr.data = NULL;
19244         uint32_t* val_vals = (uint32_t*)(val + 4);
19245         for (size_t m = 0; m < val_constr.datalen; m++) {
19246                 uint32_t val_conv_12 = val_vals[m];
19247                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19248                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19249                 val_constr.data[m] = val_conv_12_conv;
19250         }
19251         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
19252 }
19253
19254 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
19255         LDKNodeAnnouncementInfo this_ptr_conv;
19256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19257         this_ptr_conv.is_owned = false;
19258         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
19259         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19260         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19261         long ret_ref = (long)ret_var.inner;
19262         if (ret_var.is_owned) {
19263                 ret_ref |= 1;
19264         }
19265         return ret_ref;
19266 }
19267
19268 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
19269         LDKNodeAnnouncementInfo this_ptr_conv;
19270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19271         this_ptr_conv.is_owned = false;
19272         LDKNodeAnnouncement val_conv;
19273         val_conv.inner = (void*)(val & (~1));
19274         val_conv.is_owned = (val & 1) || (val == 0);
19275         val_conv = NodeAnnouncement_clone(&val_conv);
19276         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
19277 }
19278
19279 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
19280         LDKNodeFeatures features_arg_conv;
19281         features_arg_conv.inner = (void*)(features_arg & (~1));
19282         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19283         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
19284         LDKThreeBytes rgb_arg_ref;
19285         CHECK(*((uint32_t*)rgb_arg) == 3);
19286         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
19287         LDKThirtyTwoBytes alias_arg_ref;
19288         CHECK(*((uint32_t*)alias_arg) == 32);
19289         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
19290         LDKCVec_NetAddressZ addresses_arg_constr;
19291         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
19292         if (addresses_arg_constr.datalen > 0)
19293                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19294         else
19295                 addresses_arg_constr.data = NULL;
19296         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
19297         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
19298                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
19299                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
19300                 FREE((void*)addresses_arg_conv_12);
19301                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
19302         }
19303         LDKNodeAnnouncement announcement_message_arg_conv;
19304         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19305         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19306         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
19307         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
19308         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19309         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19310         long ret_ref = (long)ret_var.inner;
19311         if (ret_var.is_owned) {
19312                 ret_ref |= 1;
19313         }
19314         return ret_ref;
19315 }
19316
19317 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
19318         LDKNodeAnnouncementInfo orig_conv;
19319         orig_conv.inner = (void*)(orig & (~1));
19320         orig_conv.is_owned = false;
19321         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
19322         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19323         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19324         long ret_ref = (long)ret_var.inner;
19325         if (ret_var.is_owned) {
19326                 ret_ref |= 1;
19327         }
19328         return ret_ref;
19329 }
19330
19331 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
19332         LDKNodeAnnouncementInfo obj_conv;
19333         obj_conv.inner = (void*)(obj & (~1));
19334         obj_conv.is_owned = false;
19335         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
19336         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19337         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19338         CVec_u8Z_free(ret_var);
19339         return ret_arr;
19340 }
19341
19342 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
19343         LDKu8slice ser_ref;
19344         ser_ref.datalen = *((uint32_t*)ser);
19345         ser_ref.data = (int8_t*)(ser + 4);
19346         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19347         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
19348         return (long)ret_conv;
19349 }
19350
19351 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
19352         LDKNodeInfo this_obj_conv;
19353         this_obj_conv.inner = (void*)(this_obj & (~1));
19354         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19355         NodeInfo_free(this_obj_conv);
19356 }
19357
19358 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
19359         LDKNodeInfo this_ptr_conv;
19360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19361         this_ptr_conv.is_owned = false;
19362         LDKCVec_u64Z val_constr;
19363         val_constr.datalen = *((uint32_t*)val);
19364         if (val_constr.datalen > 0)
19365                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19366         else
19367                 val_constr.data = NULL;
19368         int64_t* val_vals = (int64_t*)(val + 4);
19369         for (size_t i = 0; i < val_constr.datalen; i++) {
19370                 int64_t val_conv_8 = val_vals[i];
19371                 val_constr.data[i] = val_conv_8;
19372         }
19373         NodeInfo_set_channels(&this_ptr_conv, val_constr);
19374 }
19375
19376 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
19377         LDKNodeInfo this_ptr_conv;
19378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19379         this_ptr_conv.is_owned = false;
19380         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
19381         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19382         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19383         long ret_ref = (long)ret_var.inner;
19384         if (ret_var.is_owned) {
19385                 ret_ref |= 1;
19386         }
19387         return ret_ref;
19388 }
19389
19390 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
19391         LDKNodeInfo this_ptr_conv;
19392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19393         this_ptr_conv.is_owned = false;
19394         LDKRoutingFees val_conv;
19395         val_conv.inner = (void*)(val & (~1));
19396         val_conv.is_owned = (val & 1) || (val == 0);
19397         val_conv = RoutingFees_clone(&val_conv);
19398         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
19399 }
19400
19401 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
19402         LDKNodeInfo this_ptr_conv;
19403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19404         this_ptr_conv.is_owned = false;
19405         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
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 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
19416         LDKNodeInfo this_ptr_conv;
19417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19418         this_ptr_conv.is_owned = false;
19419         LDKNodeAnnouncementInfo val_conv;
19420         val_conv.inner = (void*)(val & (~1));
19421         val_conv.is_owned = (val & 1) || (val == 0);
19422         val_conv = NodeAnnouncementInfo_clone(&val_conv);
19423         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
19424 }
19425
19426 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
19427         LDKCVec_u64Z channels_arg_constr;
19428         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
19429         if (channels_arg_constr.datalen > 0)
19430                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19431         else
19432                 channels_arg_constr.data = NULL;
19433         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
19434         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
19435                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
19436                 channels_arg_constr.data[i] = channels_arg_conv_8;
19437         }
19438         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
19439         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
19440         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
19441         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
19442         LDKNodeAnnouncementInfo announcement_info_arg_conv;
19443         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
19444         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
19445         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
19446         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
19447         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19448         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19449         long ret_ref = (long)ret_var.inner;
19450         if (ret_var.is_owned) {
19451                 ret_ref |= 1;
19452         }
19453         return ret_ref;
19454 }
19455
19456 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
19457         LDKNodeInfo orig_conv;
19458         orig_conv.inner = (void*)(orig & (~1));
19459         orig_conv.is_owned = false;
19460         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
19461         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19462         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19463         long ret_ref = (long)ret_var.inner;
19464         if (ret_var.is_owned) {
19465                 ret_ref |= 1;
19466         }
19467         return ret_ref;
19468 }
19469
19470 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
19471         LDKNodeInfo obj_conv;
19472         obj_conv.inner = (void*)(obj & (~1));
19473         obj_conv.is_owned = false;
19474         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
19475         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19476         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19477         CVec_u8Z_free(ret_var);
19478         return ret_arr;
19479 }
19480
19481 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
19482         LDKu8slice ser_ref;
19483         ser_ref.datalen = *((uint32_t*)ser);
19484         ser_ref.data = (int8_t*)(ser + 4);
19485         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19486         *ret_conv = NodeInfo_read(ser_ref);
19487         return (long)ret_conv;
19488 }
19489
19490 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
19491         LDKNetworkGraph obj_conv;
19492         obj_conv.inner = (void*)(obj & (~1));
19493         obj_conv.is_owned = false;
19494         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
19495         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19496         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19497         CVec_u8Z_free(ret_var);
19498         return ret_arr;
19499 }
19500
19501 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
19502         LDKu8slice ser_ref;
19503         ser_ref.datalen = *((uint32_t*)ser);
19504         ser_ref.data = (int8_t*)(ser + 4);
19505         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19506         *ret_conv = NetworkGraph_read(ser_ref);
19507         return (long)ret_conv;
19508 }
19509
19510 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
19511         LDKThirtyTwoBytes genesis_hash_ref;
19512         CHECK(*((uint32_t*)genesis_hash) == 32);
19513         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
19514         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
19515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19517         long ret_ref = (long)ret_var.inner;
19518         if (ret_var.is_owned) {
19519                 ret_ref |= 1;
19520         }
19521         return ret_ref;
19522 }
19523
19524 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
19525         LDKNetworkGraph this_arg_conv;
19526         this_arg_conv.inner = (void*)(this_arg & (~1));
19527         this_arg_conv.is_owned = false;
19528         LDKNodeAnnouncement msg_conv;
19529         msg_conv.inner = (void*)(msg & (~1));
19530         msg_conv.is_owned = false;
19531         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19532         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
19533         return (long)ret_conv;
19534 }
19535
19536 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
19537         LDKNetworkGraph this_arg_conv;
19538         this_arg_conv.inner = (void*)(this_arg & (~1));
19539         this_arg_conv.is_owned = false;
19540         LDKUnsignedNodeAnnouncement msg_conv;
19541         msg_conv.inner = (void*)(msg & (~1));
19542         msg_conv.is_owned = false;
19543         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19544         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
19545         return (long)ret_conv;
19546 }
19547
19548 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
19549         LDKNetworkGraph this_arg_conv;
19550         this_arg_conv.inner = (void*)(this_arg & (~1));
19551         this_arg_conv.is_owned = false;
19552         LDKChannelAnnouncement msg_conv;
19553         msg_conv.inner = (void*)(msg & (~1));
19554         msg_conv.is_owned = false;
19555         LDKAccess *chain_access_conv_ptr = NULL;
19556         if (chain_access != 0) {
19557                 LDKAccess chain_access_conv;
19558                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19559                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19560                 *chain_access_conv_ptr = chain_access_conv;
19561         }
19562         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19563         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
19564         return (long)ret_conv;
19565 }
19566
19567 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
19568         LDKNetworkGraph this_arg_conv;
19569         this_arg_conv.inner = (void*)(this_arg & (~1));
19570         this_arg_conv.is_owned = false;
19571         LDKUnsignedChannelAnnouncement msg_conv;
19572         msg_conv.inner = (void*)(msg & (~1));
19573         msg_conv.is_owned = false;
19574         LDKAccess *chain_access_conv_ptr = NULL;
19575         if (chain_access != 0) {
19576                 LDKAccess chain_access_conv;
19577                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19578                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19579                 *chain_access_conv_ptr = chain_access_conv;
19580         }
19581         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19582         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
19583         return (long)ret_conv;
19584 }
19585
19586 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
19587         LDKNetworkGraph this_arg_conv;
19588         this_arg_conv.inner = (void*)(this_arg & (~1));
19589         this_arg_conv.is_owned = false;
19590         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
19591 }
19592
19593 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
19594         LDKNetworkGraph this_arg_conv;
19595         this_arg_conv.inner = (void*)(this_arg & (~1));
19596         this_arg_conv.is_owned = false;
19597         LDKChannelUpdate msg_conv;
19598         msg_conv.inner = (void*)(msg & (~1));
19599         msg_conv.is_owned = false;
19600         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19601         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
19602         return (long)ret_conv;
19603 }
19604
19605 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
19606         LDKNetworkGraph this_arg_conv;
19607         this_arg_conv.inner = (void*)(this_arg & (~1));
19608         this_arg_conv.is_owned = false;
19609         LDKUnsignedChannelUpdate msg_conv;
19610         msg_conv.inner = (void*)(msg & (~1));
19611         msg_conv.is_owned = false;
19612         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19613         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
19614         return (long)ret_conv;
19615 }
19616