Update auto-generated bindings
[ldk-java] / ts / bindings.c.body
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 LDKIOError LDKIOError_from_js(int32_t ord) {
104         switch (ord) {
105                 case 0: return LDKIOError_NotFound;
106                 case 1: return LDKIOError_PermissionDenied;
107                 case 2: return LDKIOError_ConnectionRefused;
108                 case 3: return LDKIOError_ConnectionReset;
109                 case 4: return LDKIOError_ConnectionAborted;
110                 case 5: return LDKIOError_NotConnected;
111                 case 6: return LDKIOError_AddrInUse;
112                 case 7: return LDKIOError_AddrNotAvailable;
113                 case 8: return LDKIOError_BrokenPipe;
114                 case 9: return LDKIOError_AlreadyExists;
115                 case 10: return LDKIOError_WouldBlock;
116                 case 11: return LDKIOError_InvalidInput;
117                 case 12: return LDKIOError_InvalidData;
118                 case 13: return LDKIOError_TimedOut;
119                 case 14: return LDKIOError_WriteZero;
120                 case 15: return LDKIOError_Interrupted;
121                 case 16: return LDKIOError_Other;
122                 case 17: return LDKIOError_UnexpectedEof;
123         }
124         abort();
125 }
126 static inline int32_t LDKIOError_to_js(LDKIOError val) {
127         switch (val) {
128                 case LDKIOError_NotFound: return 0;
129                 case LDKIOError_PermissionDenied: return 1;
130                 case LDKIOError_ConnectionRefused: return 2;
131                 case LDKIOError_ConnectionReset: return 3;
132                 case LDKIOError_ConnectionAborted: return 4;
133                 case LDKIOError_NotConnected: return 5;
134                 case LDKIOError_AddrInUse: return 6;
135                 case LDKIOError_AddrNotAvailable: return 7;
136                 case LDKIOError_BrokenPipe: return 8;
137                 case LDKIOError_AlreadyExists: return 9;
138                 case LDKIOError_WouldBlock: return 10;
139                 case LDKIOError_InvalidInput: return 11;
140                 case LDKIOError_InvalidData: return 12;
141                 case LDKIOError_TimedOut: return 13;
142                 case LDKIOError_WriteZero: return 14;
143                 case LDKIOError_Interrupted: return 15;
144                 case LDKIOError_Other: return 16;
145                 case LDKIOError_UnexpectedEof: return 17;
146                 default: abort();
147         }
148 }
149 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
150         switch (ord) {
151                 case 0: return LDKLevel_Off;
152                 case 1: return LDKLevel_Error;
153                 case 2: return LDKLevel_Warn;
154                 case 3: return LDKLevel_Info;
155                 case 4: return LDKLevel_Debug;
156                 case 5: return LDKLevel_Trace;
157         }
158         abort();
159 }
160 static inline int32_t LDKLevel_to_js(LDKLevel val) {
161         switch (val) {
162                 case LDKLevel_Off: return 0;
163                 case LDKLevel_Error: return 1;
164                 case LDKLevel_Warn: return 2;
165                 case LDKLevel_Info: return 3;
166                 case LDKLevel_Debug: return 4;
167                 case LDKLevel_Trace: return 5;
168                 default: abort();
169         }
170 }
171 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
172         switch (ord) {
173                 case 0: return LDKNetwork_Bitcoin;
174                 case 1: return LDKNetwork_Testnet;
175                 case 2: return LDKNetwork_Regtest;
176                 case 3: return LDKNetwork_Signet;
177         }
178         abort();
179 }
180 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
181         switch (val) {
182                 case LDKNetwork_Bitcoin: return 0;
183                 case LDKNetwork_Testnet: return 1;
184                 case LDKNetwork_Regtest: return 2;
185                 case LDKNetwork_Signet: return 3;
186                 default: abort();
187         }
188 }
189 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
190         switch (ord) {
191                 case 0: return LDKSecp256k1Error_IncorrectSignature;
192                 case 1: return LDKSecp256k1Error_InvalidMessage;
193                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
194                 case 3: return LDKSecp256k1Error_InvalidSignature;
195                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
196                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
197                 case 6: return LDKSecp256k1Error_InvalidTweak;
198                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
199                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
200         }
201         abort();
202 }
203 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
204         switch (val) {
205                 case LDKSecp256k1Error_IncorrectSignature: return 0;
206                 case LDKSecp256k1Error_InvalidMessage: return 1;
207                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
208                 case LDKSecp256k1Error_InvalidSignature: return 3;
209                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
210                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
211                 case LDKSecp256k1Error_InvalidTweak: return 6;
212                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
213                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
214                 default: abort();
215         }
216 }
217 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
218         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
219         ret->datalen = *((uint32_t*)elems);
220         if (ret->datalen == 0) {
221                 ret->data = NULL;
222         } else {
223                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
224                 int8_t *java_elems = (int8_t*)(elems + 4);
225                 for (size_t i = 0; i < ret->datalen; i++) {
226                         ret->data[i] = java_elems[i];
227                 }
228         }
229         return (long)ret;
230 }
231 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
232         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
233         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
234         return ret;
235 }
236 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
237         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
238 }
239 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
240         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
241         CHECK(val->result_ok);
242         LDKChannelConfig res_var = (*val->contents.result);
243         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
244         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
245         long res_ref = (long)res_var.inner & ~1;
246         return res_ref;
247 }
248 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
249         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
250         CHECK(!val->result_ok);
251         LDKDecodeError err_var = (*val->contents.err);
252         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
253         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
254         long err_ref = (long)err_var.inner & ~1;
255         return err_ref;
256 }
257 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
258         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
259 }
260 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
261         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
262         CHECK(val->result_ok);
263         LDKOutPoint res_var = (*val->contents.result);
264         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
265         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
266         long res_ref = (long)res_var.inner & ~1;
267         return res_ref;
268 }
269 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
270         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
271         CHECK(!val->result_ok);
272         LDKDecodeError err_var = (*val->contents.err);
273         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
274         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
275         long err_ref = (long)err_var.inner & ~1;
276         return err_ref;
277 }
278 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
279         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
280 }
281 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
282         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
283         CHECK(val->result_ok);
284         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
285         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
286         return res_arr;
287 }
288 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
289         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
290         CHECK(!val->result_ok);
291         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
292         return err_conv;
293 }
294 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
295         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
296 }
297 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
298         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
299         CHECK(val->result_ok);
300         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
301         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
302         return res_arr;
303 }
304 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
305         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
306         CHECK(!val->result_ok);
307         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
308         return err_conv;
309 }
310 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
311         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
312 }
313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
314         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
315         CHECK(val->result_ok);
316         LDKTxCreationKeys res_var = (*val->contents.result);
317         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
318         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
319         long res_ref = (long)res_var.inner & ~1;
320         return res_ref;
321 }
322 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
323         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
324         CHECK(!val->result_ok);
325         LDKDecodeError err_var = (*val->contents.err);
326         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
327         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
328         long err_ref = (long)err_var.inner & ~1;
329         return err_ref;
330 }
331 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
332         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
333 }
334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
335         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
336         CHECK(val->result_ok);
337         LDKChannelPublicKeys res_var = (*val->contents.result);
338         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
339         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
340         long res_ref = (long)res_var.inner & ~1;
341         return res_ref;
342 }
343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
344         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
345         CHECK(!val->result_ok);
346         LDKDecodeError err_var = (*val->contents.err);
347         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
348         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
349         long err_ref = (long)err_var.inner & ~1;
350         return err_ref;
351 }
352 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
353         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
354 }
355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
356         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
357         CHECK(val->result_ok);
358         LDKTxCreationKeys res_var = (*val->contents.result);
359         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
360         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
361         long res_ref = (long)res_var.inner & ~1;
362         return res_ref;
363 }
364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
365         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
366         CHECK(!val->result_ok);
367         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
368         return err_conv;
369 }
370 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
371         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
372         switch(obj->tag) {
373                 case LDKCOption_u32Z_Some: {
374                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
375                 }
376                 case LDKCOption_u32Z_None: {
377                         return 0 /* LDKCOption_u32Z - None */;
378                 }
379                 default: abort();
380         }
381 }
382 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
383         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
384 }
385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
386         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
387         CHECK(val->result_ok);
388         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
389         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
390         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
391         long res_ref = (long)res_var.inner & ~1;
392         return res_ref;
393 }
394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
395         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
396         CHECK(!val->result_ok);
397         LDKDecodeError err_var = (*val->contents.err);
398         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
399         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
400         long err_ref = (long)err_var.inner & ~1;
401         return err_ref;
402 }
403 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
404         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
405 }
406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
407         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
408         CHECK(val->result_ok);
409         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
410         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
411         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
412         long res_ref = (long)res_var.inner & ~1;
413         return res_ref;
414 }
415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
416         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
417         CHECK(!val->result_ok);
418         LDKDecodeError err_var = (*val->contents.err);
419         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
420         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
421         long err_ref = (long)err_var.inner & ~1;
422         return err_ref;
423 }
424 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
425         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
426 }
427 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
428         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
429         CHECK(val->result_ok);
430         LDKChannelTransactionParameters res_var = (*val->contents.result);
431         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
432         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
433         long res_ref = (long)res_var.inner & ~1;
434         return res_ref;
435 }
436 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
437         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
438         CHECK(!val->result_ok);
439         LDKDecodeError err_var = (*val->contents.err);
440         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
441         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
442         long err_ref = (long)err_var.inner & ~1;
443         return err_ref;
444 }
445 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
446         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
447 }
448 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
449         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
450         CHECK(val->result_ok);
451         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
452         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
453         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
454         long res_ref = (long)res_var.inner & ~1;
455         return res_ref;
456 }
457 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
458         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
459         CHECK(!val->result_ok);
460         LDKDecodeError err_var = (*val->contents.err);
461         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463         long err_ref = (long)err_var.inner & ~1;
464         return err_ref;
465 }
466 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
467         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
468 }
469 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
470         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
471         CHECK(val->result_ok);
472         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
473         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
474         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
475         long res_ref = (long)res_var.inner & ~1;
476         return res_ref;
477 }
478 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
479         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
480         CHECK(!val->result_ok);
481         LDKDecodeError err_var = (*val->contents.err);
482         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
483         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
484         long err_ref = (long)err_var.inner & ~1;
485         return err_ref;
486 }
487 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
488         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
489 }
490 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
491         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
492         CHECK(val->result_ok);
493         LDKCommitmentTransaction res_var = (*val->contents.result);
494         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
495         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
496         long res_ref = (long)res_var.inner & ~1;
497         return res_ref;
498 }
499 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
500         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
501         CHECK(!val->result_ok);
502         LDKDecodeError err_var = (*val->contents.err);
503         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
504         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
505         long err_ref = (long)err_var.inner & ~1;
506         return err_ref;
507 }
508 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
509         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
510 }
511 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
512         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
513         CHECK(val->result_ok);
514         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
515         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
516         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
517         long res_ref = (long)res_var.inner & ~1;
518         return res_ref;
519 }
520 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
521         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
522         CHECK(!val->result_ok);
523         return *val->contents.err;
524 }
525 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
526         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
527 }
528 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
529         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
530         CHECK(val->result_ok);
531         LDKCVec_SignatureZ res_var = (*val->contents.result);
532         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
533         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
534         for (size_t m = 0; m < res_var.datalen; m++) {
535                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
536                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
537                 res_arr_ptr[m] = res_conv_12_arr;
538         }
539         return res_arr;
540 }
541 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
542         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
543         CHECK(!val->result_ok);
544         return *val->contents.err;
545 }
546 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
547         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
548 }
549 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
550         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
551         CHECK(val->result_ok);
552         LDKChannelMonitorUpdate res_var = (*val->contents.result);
553         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
554         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
555         long res_ref = (long)res_var.inner & ~1;
556         return res_ref;
557 }
558 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
559         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
560         CHECK(!val->result_ok);
561         LDKDecodeError err_var = (*val->contents.err);
562         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
563         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
564         long err_ref = (long)err_var.inner & ~1;
565         return err_ref;
566 }
567 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
568         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
569 }
570 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
571         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
572         CHECK(val->result_ok);
573         LDKHTLCUpdate res_var = (*val->contents.result);
574         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
575         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
576         long res_ref = (long)res_var.inner & ~1;
577         return res_ref;
578 }
579 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
580         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
581         CHECK(!val->result_ok);
582         LDKDecodeError err_var = (*val->contents.err);
583         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
584         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
585         long err_ref = (long)err_var.inner & ~1;
586         return err_ref;
587 }
588 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
589         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
590 }
591 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
592         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
593         CHECK(val->result_ok);
594         return *val->contents.result;
595 }
596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
597         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
598         CHECK(!val->result_ok);
599         LDKMonitorUpdateError err_var = (*val->contents.err);
600         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
601         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
602         long err_ref = (long)err_var.inner & ~1;
603         return err_ref;
604 }
605 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
606         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
607         LDKOutPoint a_conv;
608         a_conv.inner = (void*)(a & (~1));
609         a_conv.is_owned = (a & 1) || (a == 0);
610         a_conv = OutPoint_clone(&a_conv);
611         ret->a = a_conv;
612         LDKCVec_u8Z b_ref;
613         b_ref.datalen = *((uint32_t*)b);
614         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
615         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
616         ret->b = b_ref;
617         return (long)ret;
618 }
619 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
620         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
621         LDKOutPoint a_var = tuple->a;
622         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
623         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
624         long a_ref = (long)a_var.inner & ~1;
625         return a_ref;
626 }
627 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
628         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
629         LDKCVec_u8Z b_var = tuple->b;
630         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
631         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
632         return b_arr;
633 }
634 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
635         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
636         ret->a = a;
637         LDKCVec_u8Z b_ref;
638         b_ref.datalen = *((uint32_t*)b);
639         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
640         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
641         ret->b = b_ref;
642         return (long)ret;
643 }
644 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
645         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
646         return tuple->a;
647 }
648 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
649         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
650         LDKCVec_u8Z b_var = tuple->b;
651         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
652         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
653         return b_arr;
654 }
655 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
656         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
657         ret->datalen = *((uint32_t*)elems);
658         if (ret->datalen == 0) {
659                 ret->data = NULL;
660         } else {
661                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
662                 uint32_t *java_elems = (uint32_t*)(elems + 4);
663                 for (size_t i = 0; i < ret->datalen; i++) {
664                         uint32_t arr_elem = java_elems[i];
665                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
666                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
667                         ret->data[i] = arr_elem_conv;
668                 }
669         }
670         return (long)ret;
671 }
672 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
673         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
674         LDKThirtyTwoBytes a_ref;
675         CHECK(*((uint32_t*)a) == 32);
676         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
677         ret->a = a_ref;
678         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
679         b_constr.datalen = *((uint32_t*)b);
680         if (b_constr.datalen > 0)
681                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
682         else
683                 b_constr.data = NULL;
684         uint32_t* b_vals = (uint32_t*)(b + 4);
685         for (size_t e = 0; e < b_constr.datalen; e++) {
686                 uint32_t b_conv_30 = b_vals[e];
687                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
688                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
689                 b_constr.data[e] = b_conv_30_conv;
690         }
691         ret->b = b_constr;
692         return (long)ret;
693 }
694 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
695         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
696         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
697         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
698         return a_arr;
699 }
700 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
701         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
702         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
703         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
704         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
705         for (size_t e = 0; e < b_var.datalen; e++) {
706                 long b_conv_30_ref = (long)(&b_var.data[e]) | 1;
707                 b_arr_ptr[e] = b_conv_30_ref;
708         }
709         return b_arr;
710 }
711 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
712         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
713         ret->datalen = *((uint32_t*)elems);
714         if (ret->datalen == 0) {
715                 ret->data = NULL;
716         } else {
717                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
718                 uint32_t *java_elems = (uint32_t*)(elems + 4);
719                 for (size_t i = 0; i < ret->datalen; i++) {
720                         uint32_t arr_elem = java_elems[i];
721                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
722                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ
723                         ret->data[i] = arr_elem_conv;
724                 }
725         }
726         return (long)ret;
727 }
728 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
729         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
730         switch(obj->tag) {
731                 case LDKMonitorEvent_HTLCEvent: {
732                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
733                         CHECK((((long)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
734                         CHECK((((long)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
735                         long htlc_event_ref = (long)htlc_event_var.inner & ~1;
736                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
737                 }
738                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
739                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
740                         CHECK((((long)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
741                         CHECK((((long)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
742                         long commitment_tx_broadcasted_ref = (long)commitment_tx_broadcasted_var.inner & ~1;
743                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
744                 }
745                 default: abort();
746         }
747 }
748 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
749         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
750         ret->datalen = *((uint32_t*)elems);
751         if (ret->datalen == 0) {
752                 ret->data = NULL;
753         } else {
754                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
755                 uint32_t *java_elems = (uint32_t*)(elems + 4);
756                 for (size_t i = 0; i < ret->datalen; i++) {
757                         uint32_t arr_elem = java_elems[i];
758                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
759                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
760                         ret->data[i] = arr_elem_conv;
761                 }
762         }
763         return (long)ret;
764 }
765 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
766         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
767         for (size_t i = 0; i < ret.datalen; i++) {
768                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
769         }
770         return ret;
771 }
772 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
773         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
774         switch(obj->tag) {
775                 case LDKSpendableOutputDescriptor_StaticOutput: {
776                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
777                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
778                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
779                         long outpoint_ref = (long)outpoint_var.inner & ~1;
780                         long output_ref = ((long)&obj->static_output.output) | 1;
781                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
782                 }
783                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
784                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
785                         CHECK((((long)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
786                         CHECK((((long)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
787                         long delayed_payment_output_ref = (long)delayed_payment_output_var.inner & ~1;
788                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
789                 }
790                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
791                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
792                         CHECK((((long)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
793                         CHECK((((long)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
794                         long static_payment_output_ref = (long)static_payment_output_var.inner & ~1;
795                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
796                 }
797                 default: abort();
798         }
799 }
800 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
801         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
802         ret->datalen = *((uint32_t*)elems);
803         if (ret->datalen == 0) {
804                 ret->data = NULL;
805         } else {
806                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
807                 uint32_t *java_elems = (uint32_t*)(elems + 4);
808                 for (size_t i = 0; i < ret->datalen; i++) {
809                         uint32_t arr_elem = java_elems[i];
810                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
811                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
812                         ret->data[i] = arr_elem_conv;
813                 }
814         }
815         return (long)ret;
816 }
817 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
818         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
819         for (size_t i = 0; i < ret.datalen; i++) {
820                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
821         }
822         return ret;
823 }
824 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
825         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
826         switch(obj->tag) {
827                 case LDKEvent_FundingGenerationReady: {
828                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
829                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
830                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
831                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
832                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
833                         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;
834                 }
835                 case LDKEvent_PaymentReceived: {
836                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
837                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
838                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
839                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
840                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
841                 }
842                 case LDKEvent_PaymentSent: {
843                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
844                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
845                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
846                 }
847                 case LDKEvent_PaymentFailed: {
848                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
849                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
850                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
851                 }
852                 case LDKEvent_PendingHTLCsForwardable: {
853                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
854                 }
855                 case LDKEvent_SpendableOutputs: {
856                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
857                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
858                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
859                         for (size_t b = 0; b < outputs_var.datalen; b++) {
860                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
861                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
862                         }
863                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
864                 }
865                 default: abort();
866         }
867 }
868 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
869         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
870         ret->datalen = *((uint32_t*)elems);
871         if (ret->datalen == 0) {
872                 ret->data = NULL;
873         } else {
874                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
875                 uint32_t *java_elems = (uint32_t*)(elems + 4);
876                 for (size_t i = 0; i < ret->datalen; i++) {
877                         uint32_t arr_elem = java_elems[i];
878                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
879                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
880                         ret->data[i] = arr_elem_conv;
881                 }
882         }
883         return (long)ret;
884 }
885 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
886         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
887         for (size_t i = 0; i < ret.datalen; i++) {
888                 ret.data[i] = Event_clone(&orig->data[i]);
889         }
890         return ret;
891 }
892 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
893         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
894         ret->a = a;
895         LDKTransaction b_ref;
896         b_ref.datalen = *((uint32_t*)b);
897         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
898         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
899         b_ref.data_is_owned = false;
900         ret->b = b_ref;
901         return (long)ret;
902 }
903 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
904         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
905         return tuple->a;
906 }
907 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
908         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
909         LDKTransaction b_var = tuple->b;
910         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
911         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
912         return b_arr;
913 }
914 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
915         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
916         ret->datalen = *((uint32_t*)elems);
917         if (ret->datalen == 0) {
918                 ret->data = NULL;
919         } else {
920                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
921                 uint32_t *java_elems = (uint32_t*)(elems + 4);
922                 for (size_t i = 0; i < ret->datalen; i++) {
923                         uint32_t arr_elem = java_elems[i];
924                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
925                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
926                         ret->data[i] = arr_elem_conv;
927                 }
928         }
929         return (long)ret;
930 }
931 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
932         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
933         ret->a = a;
934         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
935         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
936         ret->b = b_conv;
937         return (long)ret;
938 }
939 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
940         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
941         return tuple->a;
942 }
943 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
944         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
945         long b_ref = ((long)&tuple->b) | 1;
946         return (long)b_ref;
947 }
948 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
949         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
950         ret->datalen = *((uint32_t*)elems);
951         if (ret->datalen == 0) {
952                 ret->data = NULL;
953         } else {
954                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
955                 uint32_t *java_elems = (uint32_t*)(elems + 4);
956                 for (size_t i = 0; i < ret->datalen; i++) {
957                         uint32_t arr_elem = java_elems[i];
958                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
959                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
960                         ret->data[i] = arr_elem_conv;
961                 }
962         }
963         return (long)ret;
964 }
965 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
966         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
967         for (size_t i = 0; i < ret.datalen; i++) {
968                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
969         }
970         return ret;
971 }
972 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
973         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
974         LDKThirtyTwoBytes a_ref;
975         CHECK(*((uint32_t*)a) == 32);
976         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
977         ret->a = a_ref;
978         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
979         b_constr.datalen = *((uint32_t*)b);
980         if (b_constr.datalen > 0)
981                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
982         else
983                 b_constr.data = NULL;
984         uint32_t* b_vals = (uint32_t*)(b + 4);
985         for (size_t z = 0; z < b_constr.datalen; z++) {
986                 uint32_t b_conv_25 = b_vals[z];
987                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
988                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
989                 b_constr.data[z] = b_conv_25_conv;
990         }
991         ret->b = b_constr;
992         return (long)ret;
993 }
994 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
995         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
996         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
997         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
998         return a_arr;
999 }
1000 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
1001         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1002         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1003         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1004         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1005         for (size_t z = 0; z < b_var.datalen; z++) {
1006                 long b_conv_25_ref = (long)(&b_var.data[z]) | 1;
1007                 b_arr_ptr[z] = b_conv_25_ref;
1008         }
1009         return b_arr;
1010 }
1011 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
1012         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1013         ret->datalen = *((uint32_t*)elems);
1014         if (ret->datalen == 0) {
1015                 ret->data = NULL;
1016         } else {
1017                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1018                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1019                 for (size_t i = 0; i < ret->datalen; i++) {
1020                         uint32_t arr_elem = java_elems[i];
1021                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1022                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ
1023                         ret->data[i] = arr_elem_conv;
1024                 }
1025         }
1026         return (long)ret;
1027 }
1028 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1029         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1030         for (size_t i = 0; i < ret.datalen; i++) {
1031                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1032         }
1033         return ret;
1034 }
1035 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
1036         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1037 }
1038 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
1039         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1040         CHECK(val->result_ok);
1041         return *val->contents.result;
1042 }
1043 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
1044         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1045         CHECK(!val->result_ok);
1046         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
1047         return err_conv;
1048 }
1049 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1050         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1051         LDKSignature a_ref;
1052         CHECK(*((uint32_t*)a) == 64);
1053         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1054         ret->a = a_ref;
1055         LDKCVec_SignatureZ b_constr;
1056         b_constr.datalen = *((uint32_t*)b);
1057         if (b_constr.datalen > 0)
1058                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1059         else
1060                 b_constr.data = NULL;
1061         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1062         for (size_t m = 0; m < b_constr.datalen; m++) {
1063                 int8_tArray b_conv_12 = b_vals[m];
1064                 LDKSignature b_conv_12_ref;
1065                 CHECK(*((uint32_t*)b_conv_12) == 64);
1066                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1067                 b_constr.data[m] = b_conv_12_ref;
1068         }
1069         ret->b = b_constr;
1070         return (long)ret;
1071 }
1072 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1073         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1074         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1075         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1076         return a_arr;
1077 }
1078 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1079         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1080         LDKCVec_SignatureZ b_var = tuple->b;
1081         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1082         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1083         for (size_t m = 0; m < b_var.datalen; m++) {
1084                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1085                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1086                 b_arr_ptr[m] = b_conv_12_arr;
1087         }
1088         return b_arr;
1089 }
1090 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1091         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1092 }
1093 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1094         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1095         CHECK(val->result_ok);
1096         long res_ref = (long)(&(*val->contents.result)) | 1;
1097         return res_ref;
1098 }
1099 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1100         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1101         CHECK(!val->result_ok);
1102         return *val->contents.err;
1103 }
1104 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1105         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1106 }
1107 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1108         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1109         CHECK(val->result_ok);
1110         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1111         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1112         return res_arr;
1113 }
1114 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1115         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1116         CHECK(!val->result_ok);
1117         return *val->contents.err;
1118 }
1119 typedef struct LDKBaseSign_JCalls {
1120         atomic_size_t refcnt;
1121         uint32_t get_per_commitment_point_meth;
1122         uint32_t release_commitment_secret_meth;
1123         uint32_t channel_keys_id_meth;
1124         uint32_t sign_counterparty_commitment_meth;
1125         uint32_t sign_holder_commitment_and_htlcs_meth;
1126         uint32_t sign_justice_transaction_meth;
1127         uint32_t sign_counterparty_htlc_transaction_meth;
1128         uint32_t sign_closing_transaction_meth;
1129         uint32_t sign_channel_announcement_meth;
1130         uint32_t ready_channel_meth;
1131 } LDKBaseSign_JCalls;
1132 static void LDKBaseSign_JCalls_free(void* this_arg) {
1133         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1134         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1135                 js_free(j_calls->get_per_commitment_point_meth);
1136                 js_free(j_calls->release_commitment_secret_meth);
1137                 js_free(j_calls->channel_keys_id_meth);
1138                 js_free(j_calls->sign_counterparty_commitment_meth);
1139                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1140                 js_free(j_calls->sign_justice_transaction_meth);
1141                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1142                 js_free(j_calls->sign_closing_transaction_meth);
1143                 js_free(j_calls->sign_channel_announcement_meth);
1144                 js_free(j_calls->ready_channel_meth);
1145                 FREE(j_calls);
1146         }
1147 }
1148 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1149         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1150         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1151         LDKPublicKey ret_ref;
1152         CHECK(*((uint32_t*)ret) == 33);
1153         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1154         return ret_ref;
1155 }
1156 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1157         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1158         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1159         LDKThirtyTwoBytes ret_ref;
1160         CHECK(*((uint32_t*)ret) == 32);
1161         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1162         return ret_ref;
1163 }
1164 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1165         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1166         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1167         LDKThirtyTwoBytes ret_ref;
1168         CHECK(*((uint32_t*)ret) == 32);
1169         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1170         return ret_ref;
1171 }
1172 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1173         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1174         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1175         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1176         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1177         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1178         long commitment_tx_ref = (long)commitment_tx_var.inner;
1179         if (commitment_tx_var.is_owned) {
1180                 commitment_tx_ref |= 1;
1181         }
1182         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1183         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1184         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1185         return ret_conv;
1186 }
1187 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1188         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1189         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1190         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1191         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1192         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1193         long commitment_tx_ref = (long)commitment_tx_var.inner;
1194         if (commitment_tx_var.is_owned) {
1195                 commitment_tx_ref |= 1;
1196         }
1197         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1198         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1199         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1200         return ret_conv;
1201 }
1202 LDKCResult_SignatureNoneZ sign_justice_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1203         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1204         LDKTransaction justice_tx_var = justice_tx;
1205         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1206         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1207         Transaction_free(justice_tx_var);
1208         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1209         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1210         LDKHTLCOutputInCommitment htlc_var = *htlc;
1211         htlc_var = HTLCOutputInCommitment_clone(htlc);
1212         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1213         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1214         long htlc_ref = (long)htlc_var.inner;
1215         if (htlc_var.is_owned) {
1216                 htlc_ref |= 1;
1217         }
1218         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);
1219         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1220         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1221         return ret_conv;
1222 }
1223 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1224         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1225         LDKTransaction htlc_tx_var = htlc_tx;
1226         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1227         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1228         Transaction_free(htlc_tx_var);
1229         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1230         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1231         LDKHTLCOutputInCommitment htlc_var = *htlc;
1232         htlc_var = HTLCOutputInCommitment_clone(htlc);
1233         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1234         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1235         long htlc_ref = (long)htlc_var.inner;
1236         if (htlc_var.is_owned) {
1237                 htlc_ref |= 1;
1238         }
1239         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);
1240         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1241         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1242         return ret_conv;
1243 }
1244 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1245         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1246         LDKTransaction closing_tx_var = closing_tx;
1247         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1248         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1249         Transaction_free(closing_tx_var);
1250         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1251         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1252         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1253         return ret_conv;
1254 }
1255 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1256         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1257         LDKUnsignedChannelAnnouncement msg_var = *msg;
1258         msg_var = UnsignedChannelAnnouncement_clone(msg);
1259         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1260         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1261         long msg_ref = (long)msg_var.inner;
1262         if (msg_var.is_owned) {
1263                 msg_ref |= 1;
1264         }
1265         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1266         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1267         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1268         return ret_conv;
1269 }
1270 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1271         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1272         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1273         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1274         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1275         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1276         long channel_parameters_ref = (long)channel_parameters_var.inner;
1277         if (channel_parameters_var.is_owned) {
1278                 channel_parameters_ref |= 1;
1279         }
1280         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1281 }
1282 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1283         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1284         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1285         return (void*) this_arg;
1286 }
1287 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1288         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1289         atomic_init(&calls->refcnt, 1);
1290         //TODO: Assign calls->o from o
1291
1292         LDKChannelPublicKeys pubkeys_conv;
1293         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1294         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1295         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1296
1297         LDKBaseSign ret = {
1298                 .this_arg = (void*) calls,
1299                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1300                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1301                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1302                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1303                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1304                 .sign_justice_transaction = sign_justice_transaction_LDKBaseSign_jcall,
1305                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1306                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1307                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1308                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1309                 .free = LDKBaseSign_JCalls_free,
1310                 .pubkeys = pubkeys_conv,
1311                 .set_pubkeys = NULL,
1312         };
1313         return ret;
1314 }
1315 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1316         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1317         *res_ptr = LDKBaseSign_init(o, pubkeys);
1318         return (long)res_ptr;
1319 }
1320 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1321         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1322         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1323         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1324         return ret_arr;
1325 }
1326
1327 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1328         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1329         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1330         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1331         return ret_arr;
1332 }
1333
1334 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1335         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1336         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1337         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1338         return ret_arr;
1339 }
1340
1341 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1342         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1343         LDKCommitmentTransaction commitment_tx_conv;
1344         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1345         commitment_tx_conv.is_owned = false;
1346         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1347         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1348         return (long)ret_conv;
1349 }
1350
1351 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1352         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1353         LDKHolderCommitmentTransaction commitment_tx_conv;
1354         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1355         commitment_tx_conv.is_owned = false;
1356         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1357         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1358         return (long)ret_conv;
1359 }
1360
1361 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_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) {
1362         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1363         LDKTransaction justice_tx_ref;
1364         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1365         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1366         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1367         justice_tx_ref.data_is_owned = true;
1368         unsigned char per_commitment_key_arr[32];
1369         CHECK(*((uint32_t*)per_commitment_key) == 32);
1370         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1371         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1372         LDKHTLCOutputInCommitment htlc_conv;
1373         htlc_conv.inner = (void*)(htlc & (~1));
1374         htlc_conv.is_owned = false;
1375         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1376         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1377         return (long)ret_conv;
1378 }
1379
1380 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_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) {
1381         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1382         LDKTransaction htlc_tx_ref;
1383         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1384         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1385         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1386         htlc_tx_ref.data_is_owned = true;
1387         LDKPublicKey per_commitment_point_ref;
1388         CHECK(*((uint32_t*)per_commitment_point) == 33);
1389         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1390         LDKHTLCOutputInCommitment htlc_conv;
1391         htlc_conv.inner = (void*)(htlc & (~1));
1392         htlc_conv.is_owned = false;
1393         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1394         *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);
1395         return (long)ret_conv;
1396 }
1397
1398 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1399         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1400         LDKTransaction closing_tx_ref;
1401         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1402         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1403         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1404         closing_tx_ref.data_is_owned = true;
1405         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1406         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1407         return (long)ret_conv;
1408 }
1409
1410 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1411         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1412         LDKUnsignedChannelAnnouncement msg_conv;
1413         msg_conv.inner = (void*)(msg & (~1));
1414         msg_conv.is_owned = false;
1415         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1416         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1417         return (long)ret_conv;
1418 }
1419
1420 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1421         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1422         LDKChannelTransactionParameters channel_parameters_conv;
1423         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1424         channel_parameters_conv.is_owned = false;
1425         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1426 }
1427
1428 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1429         if (this_arg->set_pubkeys != NULL)
1430                 this_arg->set_pubkeys(this_arg);
1431         return this_arg->pubkeys;
1432 }
1433 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1434         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1435         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1436         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438         long ret_ref = (long)ret_var.inner;
1439         if (ret_var.is_owned) {
1440                 ret_ref |= 1;
1441         }
1442         return ret_ref;
1443 }
1444
1445 typedef struct LDKSign_JCalls {
1446         atomic_size_t refcnt;
1447         LDKBaseSign_JCalls* BaseSign;
1448         uint32_t write_meth;
1449 } LDKSign_JCalls;
1450 static void LDKSign_JCalls_free(void* this_arg) {
1451         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1452         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1453                 js_free(j_calls->write_meth);
1454                 FREE(j_calls);
1455         }
1456 }
1457 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1458         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1459         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1460         LDKCVec_u8Z ret_ref;
1461         ret_ref.datalen = *((uint32_t*)ret);
1462         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1463         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1464         return ret_ref;
1465 }
1466 static void* LDKSign_JCalls_clone(const void* this_arg) {
1467         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1468         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1469         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1470         return (void*) this_arg;
1471 }
1472 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1473         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1474         atomic_init(&calls->refcnt, 1);
1475         //TODO: Assign calls->o from o
1476
1477         LDKChannelPublicKeys pubkeys_conv;
1478         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1479         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1480         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1481
1482         LDKSign ret = {
1483                 .this_arg = (void*) calls,
1484                 .write = write_LDKSign_jcall,
1485                 .clone = LDKSign_JCalls_clone,
1486                 .free = LDKSign_JCalls_free,
1487                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1488         };
1489         calls->BaseSign = ret.BaseSign.this_arg;
1490         return ret;
1491 }
1492 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1493         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1494         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1495         return (long)res_ptr;
1496 }
1497 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1498         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1499         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1500         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1501         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1502         CVec_u8Z_free(ret_var);
1503         return ret_arr;
1504 }
1505
1506 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1507         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1508         LDKThirtyTwoBytes a_ref;
1509         CHECK(*((uint32_t*)a) == 32);
1510         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1511         ret->a = a_ref;
1512         LDKChannelMonitor b_conv;
1513         b_conv.inner = (void*)(b & (~1));
1514         b_conv.is_owned = (b & 1) || (b == 0);
1515         b_conv = ChannelMonitor_clone(&b_conv);
1516         ret->b = b_conv;
1517         return (long)ret;
1518 }
1519 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1520         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1521         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1522         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1523         return a_arr;
1524 }
1525 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1526         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1527         LDKChannelMonitor b_var = tuple->b;
1528         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1529         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1530         long b_ref = (long)b_var.inner & ~1;
1531         return b_ref;
1532 }
1533 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
1534         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1535 }
1536 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
1537         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
1538         CHECK(val->result_ok);
1539         long res_ref = (long)(&(*val->contents.result)) | 1;
1540         return res_ref;
1541 }
1542 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
1543         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
1544         CHECK(!val->result_ok);
1545         LDKDecodeError err_var = (*val->contents.err);
1546         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1547         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1548         long err_ref = (long)err_var.inner & ~1;
1549         return err_ref;
1550 }
1551 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
1552         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1553         ret->datalen = *((uint32_t*)elems);
1554         if (ret->datalen == 0) {
1555                 ret->data = NULL;
1556         } else {
1557                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1558                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1559                 for (size_t i = 0; i < ret->datalen; i++) {
1560                         uint32_t arr_elem = java_elems[i];
1561                         LDKRouteHop arr_elem_conv;
1562                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1563                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1564                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1565                         ret->data[i] = arr_elem_conv;
1566                 }
1567         }
1568         return (long)ret;
1569 }
1570 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1571         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1572         for (size_t i = 0; i < ret.datalen; i++) {
1573                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1574         }
1575         return ret;
1576 }
1577 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1578         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1579         for (size_t i = 0; i < ret.datalen; i++) {
1580                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1581         }
1582         return ret;
1583 }
1584 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
1585         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1586 }
1587 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
1588         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1589         CHECK(val->result_ok);
1590         LDKRoute res_var = (*val->contents.result);
1591         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1592         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1593         long res_ref = (long)res_var.inner & ~1;
1594         return res_ref;
1595 }
1596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
1597         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1598         CHECK(!val->result_ok);
1599         LDKDecodeError err_var = (*val->contents.err);
1600         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1601         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1602         long err_ref = (long)err_var.inner & ~1;
1603         return err_ref;
1604 }
1605 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
1606         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1607         switch(obj->tag) {
1608                 case LDKCOption_u64Z_Some: {
1609                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
1610                 }
1611                 case LDKCOption_u64Z_None: {
1612                         return 0 /* LDKCOption_u64Z - None */;
1613                 }
1614                 default: abort();
1615         }
1616 }
1617 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
1618         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1619         ret->datalen = *((uint32_t*)elems);
1620         if (ret->datalen == 0) {
1621                 ret->data = NULL;
1622         } else {
1623                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1624                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1625                 for (size_t i = 0; i < ret->datalen; i++) {
1626                         uint32_t arr_elem = java_elems[i];
1627                         LDKChannelDetails arr_elem_conv;
1628                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1629                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1630                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1631                         ret->data[i] = arr_elem_conv;
1632                 }
1633         }
1634         return (long)ret;
1635 }
1636 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1637         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1638         for (size_t i = 0; i < ret.datalen; i++) {
1639                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1640         }
1641         return ret;
1642 }
1643 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
1644         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1645         ret->datalen = *((uint32_t*)elems);
1646         if (ret->datalen == 0) {
1647                 ret->data = NULL;
1648         } else {
1649                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1650                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1651                 for (size_t i = 0; i < ret->datalen; i++) {
1652                         uint32_t arr_elem = java_elems[i];
1653                         LDKRouteHint arr_elem_conv;
1654                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1655                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1656                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1657                         ret->data[i] = arr_elem_conv;
1658                 }
1659         }
1660         return (long)ret;
1661 }
1662 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1663         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1664         for (size_t i = 0; i < ret.datalen; i++) {
1665                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1666         }
1667         return ret;
1668 }
1669 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
1670         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1671 }
1672 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
1673         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1674         CHECK(val->result_ok);
1675         LDKRoute res_var = (*val->contents.result);
1676         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1677         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1678         long res_ref = (long)res_var.inner & ~1;
1679         return res_ref;
1680 }
1681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
1682         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1683         CHECK(!val->result_ok);
1684         LDKLightningError err_var = (*val->contents.err);
1685         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1686         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1687         long err_ref = (long)err_var.inner & ~1;
1688         return err_ref;
1689 }
1690 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1691         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1692         switch(obj->tag) {
1693                 case LDKErrorAction_DisconnectPeer: {
1694                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1695                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1696                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1697                         long msg_ref = (long)msg_var.inner & ~1;
1698                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1699                 }
1700                 case LDKErrorAction_IgnoreError: {
1701                         return 0 /* LDKErrorAction - IgnoreError */;
1702                 }
1703                 case LDKErrorAction_SendErrorMessage: {
1704                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1705                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1706                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1707                         long msg_ref = (long)msg_var.inner & ~1;
1708                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1709                 }
1710                 default: abort();
1711         }
1712 }
1713 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
1714         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1715         switch(obj->tag) {
1716                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1717                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1718                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1719                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1720                         long msg_ref = (long)msg_var.inner & ~1;
1721                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
1722                 }
1723                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1724                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1725                 }
1726                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1727                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1728                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1729                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1730                 }
1731                 default: abort();
1732         }
1733 }
1734 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1735         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1736         switch(obj->tag) {
1737                 case LDKMessageSendEvent_SendAcceptChannel: {
1738                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1739                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1740                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1741                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1742                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1743                         long msg_ref = (long)msg_var.inner & ~1;
1744                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1745                 }
1746                 case LDKMessageSendEvent_SendOpenChannel: {
1747                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1748                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1749                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1750                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1751                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1752                         long msg_ref = (long)msg_var.inner & ~1;
1753                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1754                 }
1755                 case LDKMessageSendEvent_SendFundingCreated: {
1756                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1757                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1758                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1759                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1760                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1761                         long msg_ref = (long)msg_var.inner & ~1;
1762                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1763                 }
1764                 case LDKMessageSendEvent_SendFundingSigned: {
1765                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1766                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1767                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1768                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770                         long msg_ref = (long)msg_var.inner & ~1;
1771                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1772                 }
1773                 case LDKMessageSendEvent_SendFundingLocked: {
1774                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1775                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1776                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1777                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1778                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1779                         long msg_ref = (long)msg_var.inner & ~1;
1780                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1781                 }
1782                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1783                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1784                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1785                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1786                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1787                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1788                         long msg_ref = (long)msg_var.inner & ~1;
1789                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1790                 }
1791                 case LDKMessageSendEvent_UpdateHTLCs: {
1792                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1793                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1794                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1795                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1796                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1797                         long updates_ref = (long)updates_var.inner & ~1;
1798                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1799                 }
1800                 case LDKMessageSendEvent_SendRevokeAndACK: {
1801                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1802                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1803                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1804                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1805                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1806                         long msg_ref = (long)msg_var.inner & ~1;
1807                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1808                 }
1809                 case LDKMessageSendEvent_SendClosingSigned: {
1810                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1811                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1812                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1813                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1814                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1815                         long msg_ref = (long)msg_var.inner & ~1;
1816                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1817                 }
1818                 case LDKMessageSendEvent_SendShutdown: {
1819                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1820                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1821                         LDKShutdown msg_var = obj->send_shutdown.msg;
1822                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1823                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1824                         long msg_ref = (long)msg_var.inner & ~1;
1825                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1826                 }
1827                 case LDKMessageSendEvent_SendChannelReestablish: {
1828                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1829                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1830                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1831                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1832                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1833                         long msg_ref = (long)msg_var.inner & ~1;
1834                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1835                 }
1836                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1837                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1838                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1839                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1840                         long msg_ref = (long)msg_var.inner & ~1;
1841                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1842                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1843                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1844                         long update_msg_ref = (long)update_msg_var.inner & ~1;
1845                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1846                 }
1847                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1848                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1849                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1850                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1851                         long msg_ref = (long)msg_var.inner & ~1;
1852                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1853                 }
1854                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1855                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1856                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1857                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1858                         long msg_ref = (long)msg_var.inner & ~1;
1859                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1860                 }
1861                 case LDKMessageSendEvent_HandleError: {
1862                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1863                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1864                         long action_ref = ((long)&obj->handle_error.action) | 1;
1865                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1866                 }
1867                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1868                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
1869                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1870                 }
1871                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1872                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1873                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1874                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1875                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1876                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1877                         long msg_ref = (long)msg_var.inner & ~1;
1878                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1879                 }
1880                 case LDKMessageSendEvent_SendShortIdsQuery: {
1881                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1882                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1883                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1884                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1885                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1886                         long msg_ref = (long)msg_var.inner & ~1;
1887                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1888                 }
1889                 case LDKMessageSendEvent_SendReplyChannelRange: {
1890                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1891                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1892                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1893                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1894                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1895                         long msg_ref = (long)msg_var.inner & ~1;
1896                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1897                 }
1898                 default: abort();
1899         }
1900 }
1901 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1902         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1903         ret->datalen = *((uint32_t*)elems);
1904         if (ret->datalen == 0) {
1905                 ret->data = NULL;
1906         } else {
1907                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1908                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1909                 for (size_t i = 0; i < ret->datalen; i++) {
1910                         uint32_t arr_elem = java_elems[i];
1911                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1912                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1913                         ret->data[i] = arr_elem_conv;
1914                 }
1915         }
1916         return (long)ret;
1917 }
1918 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1919         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1920         for (size_t i = 0; i < ret.datalen; i++) {
1921                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1922         }
1923         return ret;
1924 }
1925 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
1926         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
1927 }
1928 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
1929         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1930         CHECK(val->result_ok);
1931         return *val->contents.result;
1932 }
1933 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
1934         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
1935         CHECK(!val->result_ok);
1936         LDKLightningError err_var = (*val->contents.err);
1937         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1938         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1939         long err_ref = (long)err_var.inner & ~1;
1940         return err_ref;
1941 }
1942 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
1943         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
1944         LDKChannelAnnouncement a_conv;
1945         a_conv.inner = (void*)(a & (~1));
1946         a_conv.is_owned = (a & 1) || (a == 0);
1947         a_conv = ChannelAnnouncement_clone(&a_conv);
1948         ret->a = a_conv;
1949         LDKChannelUpdate b_conv;
1950         b_conv.inner = (void*)(b & (~1));
1951         b_conv.is_owned = (b & 1) || (b == 0);
1952         b_conv = ChannelUpdate_clone(&b_conv);
1953         ret->b = b_conv;
1954         LDKChannelUpdate c_conv;
1955         c_conv.inner = (void*)(c & (~1));
1956         c_conv.is_owned = (c & 1) || (c == 0);
1957         c_conv = ChannelUpdate_clone(&c_conv);
1958         ret->c = c_conv;
1959         return (long)ret;
1960 }
1961 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
1962         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1963         LDKChannelAnnouncement a_var = tuple->a;
1964         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1965         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1966         long a_ref = (long)a_var.inner & ~1;
1967         return a_ref;
1968 }
1969 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
1970         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1971         LDKChannelUpdate b_var = tuple->b;
1972         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1973         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1974         long b_ref = (long)b_var.inner & ~1;
1975         return b_ref;
1976 }
1977 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
1978         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
1979         LDKChannelUpdate c_var = tuple->c;
1980         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1981         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1982         long c_ref = (long)c_var.inner & ~1;
1983         return c_ref;
1984 }
1985 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
1986         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
1987         ret->datalen = *((uint32_t*)elems);
1988         if (ret->datalen == 0) {
1989                 ret->data = NULL;
1990         } else {
1991                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
1992                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1993                 for (size_t i = 0; i < ret->datalen; i++) {
1994                         uint32_t arr_elem = java_elems[i];
1995                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
1996                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
1997                         ret->data[i] = arr_elem_conv;
1998                 }
1999         }
2000         return (long)ret;
2001 }
2002 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2003         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2004         for (size_t i = 0; i < ret.datalen; i++) {
2005                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2006         }
2007         return ret;
2008 }
2009 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
2010         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2011         ret->datalen = *((uint32_t*)elems);
2012         if (ret->datalen == 0) {
2013                 ret->data = NULL;
2014         } else {
2015                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2016                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2017                 for (size_t i = 0; i < ret->datalen; i++) {
2018                         uint32_t arr_elem = java_elems[i];
2019                         LDKNodeAnnouncement arr_elem_conv;
2020                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2021                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2022                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2023                         ret->data[i] = arr_elem_conv;
2024                 }
2025         }
2026         return (long)ret;
2027 }
2028 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2029         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2030         for (size_t i = 0; i < ret.datalen; i++) {
2031                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2032         }
2033         return ret;
2034 }
2035 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
2036         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2037 }
2038 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
2039         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2040         CHECK(val->result_ok);
2041         return *val->contents.result;
2042 }
2043 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
2044         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2045         CHECK(!val->result_ok);
2046         LDKLightningError err_var = (*val->contents.err);
2047         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2048         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2049         long err_ref = (long)err_var.inner & ~1;
2050         return err_ref;
2051 }
2052 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
2053         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2054 }
2055 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
2056         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2057         CHECK(val->result_ok);
2058         LDKCVec_u8Z res_var = (*val->contents.result);
2059         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2060         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2061         return res_arr;
2062 }
2063 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
2064         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2065         CHECK(!val->result_ok);
2066         LDKPeerHandleError err_var = (*val->contents.err);
2067         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2068         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2069         long err_ref = (long)err_var.inner & ~1;
2070         return err_ref;
2071 }
2072 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
2073         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2074 }
2075 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
2076         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2077         CHECK(val->result_ok);
2078         return *val->contents.result;
2079 }
2080 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
2081         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2082         CHECK(!val->result_ok);
2083         LDKPeerHandleError err_var = (*val->contents.err);
2084         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2085         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2086         long err_ref = (long)err_var.inner & ~1;
2087         return err_ref;
2088 }
2089 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
2090         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2091 }
2092 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
2093         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2094         CHECK(val->result_ok);
2095         return *val->contents.result;
2096 }
2097 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
2098         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2099         CHECK(!val->result_ok);
2100         LDKPeerHandleError err_var = (*val->contents.err);
2101         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2102         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2103         long err_ref = (long)err_var.inner & ~1;
2104         return err_ref;
2105 }
2106 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
2107         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2108 }
2109 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
2110         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2111         CHECK(val->result_ok);
2112         long res_ref = ((long)&(*val->contents.result)) | 1;
2113         return (long)res_ref;
2114 }
2115 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
2116         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2117         CHECK(!val->result_ok);
2118         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
2119         return err_conv;
2120 }
2121 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
2122         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2123         switch(obj->tag) {
2124                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2125                         long some_ref = (long)(&obj->some) | 1;
2126                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
2127                 }
2128                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2129                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
2130                 }
2131                 default: abort();
2132         }
2133 }
2134 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
2135         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
2136 }
2137 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
2138         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2139         CHECK(val->result_ok);
2140         LDKDirectionalChannelInfo res_var = (*val->contents.result);
2141         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143         long res_ref = (long)res_var.inner & ~1;
2144         return res_ref;
2145 }
2146 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
2147         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
2148         CHECK(!val->result_ok);
2149         LDKDecodeError err_var = (*val->contents.err);
2150         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2151         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2152         long err_ref = (long)err_var.inner & ~1;
2153         return err_ref;
2154 }
2155 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
2156         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
2157 }
2158 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
2159         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2160         CHECK(val->result_ok);
2161         LDKChannelInfo res_var = (*val->contents.result);
2162         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2163         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2164         long res_ref = (long)res_var.inner & ~1;
2165         return res_ref;
2166 }
2167 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
2168         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
2169         CHECK(!val->result_ok);
2170         LDKDecodeError err_var = (*val->contents.err);
2171         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2172         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2173         long err_ref = (long)err_var.inner & ~1;
2174         return err_ref;
2175 }
2176 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
2177         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2178 }
2179 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
2180         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2181         CHECK(val->result_ok);
2182         LDKRoutingFees res_var = (*val->contents.result);
2183         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2184         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2185         long res_ref = (long)res_var.inner & ~1;
2186         return res_ref;
2187 }
2188 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
2189         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2190         CHECK(!val->result_ok);
2191         LDKDecodeError err_var = (*val->contents.err);
2192         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2193         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2194         long err_ref = (long)err_var.inner & ~1;
2195         return err_ref;
2196 }
2197 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2198         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2199         switch(obj->tag) {
2200                 case LDKNetAddress_IPv4: {
2201                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2202                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2203                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2204                 }
2205                 case LDKNetAddress_IPv6: {
2206                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2207                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2208                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2209                 }
2210                 case LDKNetAddress_OnionV2: {
2211                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2212                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2213                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2214                 }
2215                 case LDKNetAddress_OnionV3: {
2216                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2217                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2218                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2219                 }
2220                 default: abort();
2221         }
2222 }
2223 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2224         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2225         ret->datalen = *((uint32_t*)elems);
2226         if (ret->datalen == 0) {
2227                 ret->data = NULL;
2228         } else {
2229                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2230                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2231                 for (size_t i = 0; i < ret->datalen; i++) {
2232                         uint32_t arr_elem = java_elems[i];
2233                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2234                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2235                         ret->data[i] = arr_elem_conv;
2236                 }
2237         }
2238         return (long)ret;
2239 }
2240 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2241         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2242         for (size_t i = 0; i < ret.datalen; i++) {
2243                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2244         }
2245         return ret;
2246 }
2247 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
2248         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2249 }
2250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
2251         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2252         CHECK(val->result_ok);
2253         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2254         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2255         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2256         long res_ref = (long)res_var.inner & ~1;
2257         return res_ref;
2258 }
2259 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
2260         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2261         CHECK(!val->result_ok);
2262         LDKDecodeError err_var = (*val->contents.err);
2263         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2264         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2265         long err_ref = (long)err_var.inner & ~1;
2266         return err_ref;
2267 }
2268 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
2269         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2270         ret->datalen = *((uint32_t*)elems);
2271         if (ret->datalen == 0) {
2272                 ret->data = NULL;
2273         } else {
2274                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2275                 int64_t *java_elems = (int64_t*)(elems + 4);
2276                 for (size_t i = 0; i < ret->datalen; i++) {
2277                         ret->data[i] = java_elems[i];
2278                 }
2279         }
2280         return (long)ret;
2281 }
2282 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2283         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2284         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2285         return ret;
2286 }
2287 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
2288         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
2289 }
2290 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
2291         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
2292         CHECK(val->result_ok);
2293         LDKNodeInfo res_var = (*val->contents.result);
2294         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2295         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2296         long res_ref = (long)res_var.inner & ~1;
2297         return res_ref;
2298 }
2299 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
2300         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
2301         CHECK(!val->result_ok);
2302         LDKDecodeError err_var = (*val->contents.err);
2303         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2304         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2305         long err_ref = (long)err_var.inner & ~1;
2306         return err_ref;
2307 }
2308 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
2309         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
2310 }
2311 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
2312         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
2313         CHECK(val->result_ok);
2314         LDKNetworkGraph res_var = (*val->contents.result);
2315         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2316         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2317         long res_ref = (long)res_var.inner & ~1;
2318         return res_ref;
2319 }
2320 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
2321         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
2322         CHECK(!val->result_ok);
2323         LDKDecodeError err_var = (*val->contents.err);
2324         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2325         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2326         long err_ref = (long)err_var.inner & ~1;
2327         return err_ref;
2328 }
2329 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
2330         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
2331 }
2332 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
2333         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2334         CHECK(val->result_ok);
2335         LDKInitFeatures res_var = (*val->contents.result);
2336         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2337         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2338         long res_ref = (long)res_var.inner & ~1;
2339         return res_ref;
2340 }
2341 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
2342         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2343         CHECK(!val->result_ok);
2344         LDKDecodeError err_var = (*val->contents.err);
2345         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2346         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2347         long err_ref = (long)err_var.inner & ~1;
2348         return err_ref;
2349 }
2350 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
2351         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
2352 }
2353 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
2354         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2355         CHECK(val->result_ok);
2356         LDKNodeFeatures res_var = (*val->contents.result);
2357         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2358         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2359         long res_ref = (long)res_var.inner & ~1;
2360         return res_ref;
2361 }
2362 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
2363         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2364         CHECK(!val->result_ok);
2365         LDKDecodeError err_var = (*val->contents.err);
2366         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368         long err_ref = (long)err_var.inner & ~1;
2369         return err_ref;
2370 }
2371 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
2372         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
2373 }
2374 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
2375         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2376         CHECK(val->result_ok);
2377         LDKChannelFeatures res_var = (*val->contents.result);
2378         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2379         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2380         long res_ref = (long)res_var.inner & ~1;
2381         return res_ref;
2382 }
2383 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
2384         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2385         CHECK(!val->result_ok);
2386         LDKDecodeError err_var = (*val->contents.err);
2387         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2388         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2389         long err_ref = (long)err_var.inner & ~1;
2390         return err_ref;
2391 }
2392 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
2393         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
2394 }
2395 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
2396         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2397         CHECK(val->result_ok);
2398         LDKInvoiceFeatures res_var = (*val->contents.result);
2399         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2400         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2401         long res_ref = (long)res_var.inner & ~1;
2402         return res_ref;
2403 }
2404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
2405         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2406         CHECK(!val->result_ok);
2407         LDKDecodeError err_var = (*val->contents.err);
2408         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2409         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2410         long err_ref = (long)err_var.inner & ~1;
2411         return err_ref;
2412 }
2413 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
2414         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
2415 }
2416 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
2417         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
2418         CHECK(val->result_ok);
2419         long res_ref = ((long)&(*val->contents.result)) | 1;
2420         return res_ref;
2421 }
2422 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
2423         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
2424         CHECK(!val->result_ok);
2425         return *val->contents.err;
2426 }
2427 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
2428         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
2429 }
2430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
2431         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
2432         CHECK(val->result_ok);
2433         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
2434         *res_conv = (*val->contents.result);
2435         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
2436         return (long)res_conv;
2437 }
2438 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
2439         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
2440         CHECK(!val->result_ok);
2441         LDKDecodeError err_var = (*val->contents.err);
2442         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2443         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2444         long err_ref = (long)err_var.inner & ~1;
2445         return err_ref;
2446 }
2447 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
2448         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
2449         ret->datalen = *((uint32_t*)elems);
2450         if (ret->datalen == 0) {
2451                 ret->data = NULL;
2452         } else {
2453                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
2454                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2455                 for (size_t i = 0; i < ret->datalen; i++) {
2456                         uint32_t arr_elem = java_elems[i];
2457                         LDKUpdateAddHTLC arr_elem_conv;
2458                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2459                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2460                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
2461                         ret->data[i] = arr_elem_conv;
2462                 }
2463         }
2464         return (long)ret;
2465 }
2466 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
2467         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
2468         for (size_t i = 0; i < ret.datalen; i++) {
2469                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
2470         }
2471         return ret;
2472 }
2473 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
2474         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
2475         ret->datalen = *((uint32_t*)elems);
2476         if (ret->datalen == 0) {
2477                 ret->data = NULL;
2478         } else {
2479                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
2480                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2481                 for (size_t i = 0; i < ret->datalen; i++) {
2482                         uint32_t arr_elem = java_elems[i];
2483                         LDKUpdateFulfillHTLC arr_elem_conv;
2484                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2485                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2486                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
2487                         ret->data[i] = arr_elem_conv;
2488                 }
2489         }
2490         return (long)ret;
2491 }
2492 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
2493         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
2494         for (size_t i = 0; i < ret.datalen; i++) {
2495                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
2496         }
2497         return ret;
2498 }
2499 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
2500         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
2501         ret->datalen = *((uint32_t*)elems);
2502         if (ret->datalen == 0) {
2503                 ret->data = NULL;
2504         } else {
2505                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
2506                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2507                 for (size_t i = 0; i < ret->datalen; i++) {
2508                         uint32_t arr_elem = java_elems[i];
2509                         LDKUpdateFailHTLC arr_elem_conv;
2510                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2511                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2512                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
2513                         ret->data[i] = arr_elem_conv;
2514                 }
2515         }
2516         return (long)ret;
2517 }
2518 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
2519         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
2520         for (size_t i = 0; i < ret.datalen; i++) {
2521                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
2522         }
2523         return ret;
2524 }
2525 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
2526         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
2527         ret->datalen = *((uint32_t*)elems);
2528         if (ret->datalen == 0) {
2529                 ret->data = NULL;
2530         } else {
2531                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
2532                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2533                 for (size_t i = 0; i < ret->datalen; i++) {
2534                         uint32_t arr_elem = java_elems[i];
2535                         LDKUpdateFailMalformedHTLC arr_elem_conv;
2536                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2537                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2538                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
2539                         ret->data[i] = arr_elem_conv;
2540                 }
2541         }
2542         return (long)ret;
2543 }
2544 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
2545         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
2546         for (size_t i = 0; i < ret.datalen; i++) {
2547                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
2548         }
2549         return ret;
2550 }
2551 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
2552         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
2553 }
2554 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
2555         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
2556         CHECK(val->result_ok);
2557         LDKAcceptChannel res_var = (*val->contents.result);
2558         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2559         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2560         long res_ref = (long)res_var.inner & ~1;
2561         return res_ref;
2562 }
2563 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
2564         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
2565         CHECK(!val->result_ok);
2566         LDKDecodeError err_var = (*val->contents.err);
2567         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2568         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2569         long err_ref = (long)err_var.inner & ~1;
2570         return err_ref;
2571 }
2572 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
2573         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
2574 }
2575 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
2576         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
2577         CHECK(val->result_ok);
2578         LDKAnnouncementSignatures res_var = (*val->contents.result);
2579         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2580         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2581         long res_ref = (long)res_var.inner & ~1;
2582         return res_ref;
2583 }
2584 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
2585         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
2586         CHECK(!val->result_ok);
2587         LDKDecodeError err_var = (*val->contents.err);
2588         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2589         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2590         long err_ref = (long)err_var.inner & ~1;
2591         return err_ref;
2592 }
2593 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
2594         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
2595 }
2596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
2597         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
2598         CHECK(val->result_ok);
2599         LDKChannelReestablish res_var = (*val->contents.result);
2600         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602         long res_ref = (long)res_var.inner & ~1;
2603         return res_ref;
2604 }
2605 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
2606         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
2607         CHECK(!val->result_ok);
2608         LDKDecodeError err_var = (*val->contents.err);
2609         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2610         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2611         long err_ref = (long)err_var.inner & ~1;
2612         return err_ref;
2613 }
2614 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
2615         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
2616 }
2617 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
2618         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
2619         CHECK(val->result_ok);
2620         LDKClosingSigned res_var = (*val->contents.result);
2621         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2622         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2623         long res_ref = (long)res_var.inner & ~1;
2624         return res_ref;
2625 }
2626 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
2627         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
2628         CHECK(!val->result_ok);
2629         LDKDecodeError err_var = (*val->contents.err);
2630         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2631         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2632         long err_ref = (long)err_var.inner & ~1;
2633         return err_ref;
2634 }
2635 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
2636         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
2637 }
2638 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
2639         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
2640         CHECK(val->result_ok);
2641         LDKCommitmentSigned res_var = (*val->contents.result);
2642         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2643         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2644         long res_ref = (long)res_var.inner & ~1;
2645         return res_ref;
2646 }
2647 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
2648         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
2649         CHECK(!val->result_ok);
2650         LDKDecodeError err_var = (*val->contents.err);
2651         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2652         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2653         long err_ref = (long)err_var.inner & ~1;
2654         return err_ref;
2655 }
2656 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
2657         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
2658 }
2659 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
2660         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
2661         CHECK(val->result_ok);
2662         LDKFundingCreated res_var = (*val->contents.result);
2663         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2664         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2665         long res_ref = (long)res_var.inner & ~1;
2666         return res_ref;
2667 }
2668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
2669         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
2670         CHECK(!val->result_ok);
2671         LDKDecodeError err_var = (*val->contents.err);
2672         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2673         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2674         long err_ref = (long)err_var.inner & ~1;
2675         return err_ref;
2676 }
2677 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
2678         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
2679 }
2680 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
2681         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
2682         CHECK(val->result_ok);
2683         LDKFundingSigned res_var = (*val->contents.result);
2684         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2685         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2686         long res_ref = (long)res_var.inner & ~1;
2687         return res_ref;
2688 }
2689 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
2690         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
2691         CHECK(!val->result_ok);
2692         LDKDecodeError err_var = (*val->contents.err);
2693         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2694         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2695         long err_ref = (long)err_var.inner & ~1;
2696         return err_ref;
2697 }
2698 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
2699         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
2700 }
2701 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
2702         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
2703         CHECK(val->result_ok);
2704         LDKFundingLocked res_var = (*val->contents.result);
2705         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2706         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2707         long res_ref = (long)res_var.inner & ~1;
2708         return res_ref;
2709 }
2710 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
2711         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
2712         CHECK(!val->result_ok);
2713         LDKDecodeError err_var = (*val->contents.err);
2714         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2715         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2716         long err_ref = (long)err_var.inner & ~1;
2717         return err_ref;
2718 }
2719 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
2720         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
2721 }
2722 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
2723         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
2724         CHECK(val->result_ok);
2725         LDKInit res_var = (*val->contents.result);
2726         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2727         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2728         long res_ref = (long)res_var.inner & ~1;
2729         return res_ref;
2730 }
2731 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
2732         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
2733         CHECK(!val->result_ok);
2734         LDKDecodeError err_var = (*val->contents.err);
2735         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737         long err_ref = (long)err_var.inner & ~1;
2738         return err_ref;
2739 }
2740 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
2741         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
2742 }
2743 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
2744         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
2745         CHECK(val->result_ok);
2746         LDKOpenChannel res_var = (*val->contents.result);
2747         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2748         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2749         long res_ref = (long)res_var.inner & ~1;
2750         return res_ref;
2751 }
2752 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
2753         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
2754         CHECK(!val->result_ok);
2755         LDKDecodeError err_var = (*val->contents.err);
2756         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2757         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2758         long err_ref = (long)err_var.inner & ~1;
2759         return err_ref;
2760 }
2761 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
2762         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
2763 }
2764 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
2765         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
2766         CHECK(val->result_ok);
2767         LDKRevokeAndACK res_var = (*val->contents.result);
2768         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2769         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2770         long res_ref = (long)res_var.inner & ~1;
2771         return res_ref;
2772 }
2773 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
2774         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
2775         CHECK(!val->result_ok);
2776         LDKDecodeError err_var = (*val->contents.err);
2777         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2778         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2779         long err_ref = (long)err_var.inner & ~1;
2780         return err_ref;
2781 }
2782 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
2783         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
2784 }
2785 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
2786         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
2787         CHECK(val->result_ok);
2788         LDKShutdown res_var = (*val->contents.result);
2789         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         long res_ref = (long)res_var.inner & ~1;
2792         return res_ref;
2793 }
2794 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
2795         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
2796         CHECK(!val->result_ok);
2797         LDKDecodeError err_var = (*val->contents.err);
2798         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2799         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2800         long err_ref = (long)err_var.inner & ~1;
2801         return err_ref;
2802 }
2803 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
2804         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
2805 }
2806 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
2807         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
2808         CHECK(val->result_ok);
2809         LDKUpdateFailHTLC res_var = (*val->contents.result);
2810         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2811         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2812         long res_ref = (long)res_var.inner & ~1;
2813         return res_ref;
2814 }
2815 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
2816         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
2817         CHECK(!val->result_ok);
2818         LDKDecodeError err_var = (*val->contents.err);
2819         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2820         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2821         long err_ref = (long)err_var.inner & ~1;
2822         return err_ref;
2823 }
2824 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
2825         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
2826 }
2827 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
2828         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
2829         CHECK(val->result_ok);
2830         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
2831         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2832         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2833         long res_ref = (long)res_var.inner & ~1;
2834         return res_ref;
2835 }
2836 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
2837         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
2838         CHECK(!val->result_ok);
2839         LDKDecodeError err_var = (*val->contents.err);
2840         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2841         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2842         long err_ref = (long)err_var.inner & ~1;
2843         return err_ref;
2844 }
2845 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
2846         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
2847 }
2848 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
2849         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
2850         CHECK(val->result_ok);
2851         LDKUpdateFee res_var = (*val->contents.result);
2852         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2853         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2854         long res_ref = (long)res_var.inner & ~1;
2855         return res_ref;
2856 }
2857 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
2858         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
2859         CHECK(!val->result_ok);
2860         LDKDecodeError err_var = (*val->contents.err);
2861         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2862         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2863         long err_ref = (long)err_var.inner & ~1;
2864         return err_ref;
2865 }
2866 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
2867         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
2868 }
2869 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
2870         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
2871         CHECK(val->result_ok);
2872         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
2873         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2874         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2875         long res_ref = (long)res_var.inner & ~1;
2876         return res_ref;
2877 }
2878 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
2879         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
2880         CHECK(!val->result_ok);
2881         LDKDecodeError err_var = (*val->contents.err);
2882         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2883         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2884         long err_ref = (long)err_var.inner & ~1;
2885         return err_ref;
2886 }
2887 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
2888         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
2889 }
2890 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
2891         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
2892         CHECK(val->result_ok);
2893         LDKUpdateAddHTLC res_var = (*val->contents.result);
2894         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2895         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2896         long res_ref = (long)res_var.inner & ~1;
2897         return res_ref;
2898 }
2899 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
2900         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
2901         CHECK(!val->result_ok);
2902         LDKDecodeError err_var = (*val->contents.err);
2903         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2904         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2905         long err_ref = (long)err_var.inner & ~1;
2906         return err_ref;
2907 }
2908 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
2909         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
2910 }
2911 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
2912         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
2913         CHECK(val->result_ok);
2914         LDKPing res_var = (*val->contents.result);
2915         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2916         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2917         long res_ref = (long)res_var.inner & ~1;
2918         return res_ref;
2919 }
2920 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
2921         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
2922         CHECK(!val->result_ok);
2923         LDKDecodeError err_var = (*val->contents.err);
2924         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2925         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2926         long err_ref = (long)err_var.inner & ~1;
2927         return err_ref;
2928 }
2929 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
2930         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
2931 }
2932 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
2933         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
2934         CHECK(val->result_ok);
2935         LDKPong res_var = (*val->contents.result);
2936         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938         long res_ref = (long)res_var.inner & ~1;
2939         return res_ref;
2940 }
2941 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
2942         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
2943         CHECK(!val->result_ok);
2944         LDKDecodeError err_var = (*val->contents.err);
2945         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2946         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2947         long err_ref = (long)err_var.inner & ~1;
2948         return err_ref;
2949 }
2950 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2951         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2952 }
2953 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2954         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2955         CHECK(val->result_ok);
2956         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
2957         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2958         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2959         long res_ref = (long)res_var.inner & ~1;
2960         return res_ref;
2961 }
2962 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2963         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2964         CHECK(!val->result_ok);
2965         LDKDecodeError err_var = (*val->contents.err);
2966         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2967         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2968         long err_ref = (long)err_var.inner & ~1;
2969         return err_ref;
2970 }
2971 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2972         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2973 }
2974 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2975         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2976         CHECK(val->result_ok);
2977         LDKChannelAnnouncement res_var = (*val->contents.result);
2978         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2979         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2980         long res_ref = (long)res_var.inner & ~1;
2981         return res_ref;
2982 }
2983 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2984         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2985         CHECK(!val->result_ok);
2986         LDKDecodeError err_var = (*val->contents.err);
2987         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2988         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2989         long err_ref = (long)err_var.inner & ~1;
2990         return err_ref;
2991 }
2992 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
2993         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
2994 }
2995 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
2996         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
2997         CHECK(val->result_ok);
2998         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
2999         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3000         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3001         long res_ref = (long)res_var.inner & ~1;
3002         return res_ref;
3003 }
3004 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3005         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3006         CHECK(!val->result_ok);
3007         LDKDecodeError err_var = (*val->contents.err);
3008         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3009         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3010         long err_ref = (long)err_var.inner & ~1;
3011         return err_ref;
3012 }
3013 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3014         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3015 }
3016 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3017         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3018         CHECK(val->result_ok);
3019         LDKChannelUpdate res_var = (*val->contents.result);
3020         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3021         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3022         long res_ref = (long)res_var.inner & ~1;
3023         return res_ref;
3024 }
3025 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3026         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3027         CHECK(!val->result_ok);
3028         LDKDecodeError err_var = (*val->contents.err);
3029         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3030         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3031         long err_ref = (long)err_var.inner & ~1;
3032         return err_ref;
3033 }
3034 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
3035         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3036 }
3037 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
3038         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3039         CHECK(val->result_ok);
3040         LDKErrorMessage res_var = (*val->contents.result);
3041         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3042         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3043         long res_ref = (long)res_var.inner & ~1;
3044         return res_ref;
3045 }
3046 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
3047         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3048         CHECK(!val->result_ok);
3049         LDKDecodeError err_var = (*val->contents.err);
3050         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052         long err_ref = (long)err_var.inner & ~1;
3053         return err_ref;
3054 }
3055 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3056         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3057 }
3058 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3059         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3060         CHECK(val->result_ok);
3061         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
3062         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3063         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3064         long res_ref = (long)res_var.inner & ~1;
3065         return res_ref;
3066 }
3067 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3068         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3069         CHECK(!val->result_ok);
3070         LDKDecodeError err_var = (*val->contents.err);
3071         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3072         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3073         long err_ref = (long)err_var.inner & ~1;
3074         return err_ref;
3075 }
3076 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3077         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3078 }
3079 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3080         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3081         CHECK(val->result_ok);
3082         LDKNodeAnnouncement res_var = (*val->contents.result);
3083         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3084         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3085         long res_ref = (long)res_var.inner & ~1;
3086         return res_ref;
3087 }
3088 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3089         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3090         CHECK(!val->result_ok);
3091         LDKDecodeError err_var = (*val->contents.err);
3092         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3093         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3094         long err_ref = (long)err_var.inner & ~1;
3095         return err_ref;
3096 }
3097 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
3098         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3099 }
3100 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
3101         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3102         CHECK(val->result_ok);
3103         LDKQueryShortChannelIds res_var = (*val->contents.result);
3104         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3105         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3106         long res_ref = (long)res_var.inner & ~1;
3107         return res_ref;
3108 }
3109 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
3110         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3111         CHECK(!val->result_ok);
3112         LDKDecodeError err_var = (*val->contents.err);
3113         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3114         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3115         long err_ref = (long)err_var.inner & ~1;
3116         return err_ref;
3117 }
3118 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
3119         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3120 }
3121 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
3122         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3123         CHECK(val->result_ok);
3124         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
3125         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3126         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3127         long res_ref = (long)res_var.inner & ~1;
3128         return res_ref;
3129 }
3130 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
3131         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3132         CHECK(!val->result_ok);
3133         LDKDecodeError err_var = (*val->contents.err);
3134         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3135         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3136         long err_ref = (long)err_var.inner & ~1;
3137         return err_ref;
3138 }
3139 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3140         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3141 }
3142 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3143         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3144         CHECK(val->result_ok);
3145         LDKQueryChannelRange res_var = (*val->contents.result);
3146         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148         long res_ref = (long)res_var.inner & ~1;
3149         return res_ref;
3150 }
3151 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3152         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3153         CHECK(!val->result_ok);
3154         LDKDecodeError err_var = (*val->contents.err);
3155         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3156         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3157         long err_ref = (long)err_var.inner & ~1;
3158         return err_ref;
3159 }
3160 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3161         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3162 }
3163 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3164         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3165         CHECK(val->result_ok);
3166         LDKReplyChannelRange res_var = (*val->contents.result);
3167         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3168         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3169         long res_ref = (long)res_var.inner & ~1;
3170         return res_ref;
3171 }
3172 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3173         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3174         CHECK(!val->result_ok);
3175         LDKDecodeError err_var = (*val->contents.err);
3176         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3177         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3178         long err_ref = (long)err_var.inner & ~1;
3179         return err_ref;
3180 }
3181 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
3182         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3183 }
3184 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
3185         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3186         CHECK(val->result_ok);
3187         LDKGossipTimestampFilter res_var = (*val->contents.result);
3188         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3189         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3190         long res_ref = (long)res_var.inner & ~1;
3191         return res_ref;
3192 }
3193 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
3194         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3195         CHECK(!val->result_ok);
3196         LDKDecodeError err_var = (*val->contents.err);
3197         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3198         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3199         long err_ref = (long)err_var.inner & ~1;
3200         return err_ref;
3201 }
3202 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
3203         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
3204 }
3205 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
3206         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3207         CHECK(val->result_ok);
3208         long res_ref = ((long)&(*val->contents.result)) | 1;
3209         return res_ref;
3210 }
3211 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
3212         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
3213         CHECK(!val->result_ok);
3214         LDKDecodeError err_var = (*val->contents.err);
3215         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3216         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3217         long err_ref = (long)err_var.inner & ~1;
3218         return err_ref;
3219 }
3220 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
3221         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
3222 }
3223 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
3224         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3225         CHECK(val->result_ok);
3226         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3227         *ret = Sign_clone(&(*val->contents.result));
3228         return (long)ret;
3229 }
3230 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
3231         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3232         CHECK(!val->result_ok);
3233         LDKDecodeError err_var = (*val->contents.err);
3234         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3235         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3236         long err_ref = (long)err_var.inner & ~1;
3237         return err_ref;
3238 }
3239 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3240         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3241         for (size_t i = 0; i < ret.datalen; i++) {
3242                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3243         }
3244         return ret;
3245 }
3246 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
3247         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
3248 }
3249 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
3250         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3251         CHECK(val->result_ok);
3252         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3253         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
3254         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
3255         for (size_t m = 0; m < res_var.datalen; m++) {
3256                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
3257                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3258                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
3259                 res_arr_ptr[m] = res_conv_12_arr;
3260         }
3261         return res_arr;
3262 }
3263 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
3264         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3265         CHECK(!val->result_ok);
3266         return *val->contents.err;
3267 }
3268 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
3269         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
3270 }
3271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
3272         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3273         CHECK(val->result_ok);
3274         LDKInMemorySigner 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_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
3281         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(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 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
3290         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
3291         ret->datalen = *((uint32_t*)elems);
3292         if (ret->datalen == 0) {
3293                 ret->data = NULL;
3294         } else {
3295                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
3296                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3297                 for (size_t i = 0; i < ret->datalen; i++) {
3298                         uint32_t arr_elem = java_elems[i];
3299                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
3300                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
3301                         ret->data[i] = arr_elem_conv;
3302                 }
3303         }
3304         return (long)ret;
3305 }
3306 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3307         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3308         for (size_t i = 0; i < ret.datalen; i++) {
3309                 ret.data[i] = TxOut_clone(&orig->data[i]);
3310         }
3311         return ret;
3312 }
3313 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
3314         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
3315 }
3316 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
3317         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3318         CHECK(val->result_ok);
3319         LDKTransaction res_var = (*val->contents.result);
3320         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3321         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3322         return res_arr;
3323 }
3324 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
3325         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3326         CHECK(!val->result_ok);
3327         return *val->contents.err;
3328 }
3329 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
3330         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
3331 }
3332 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
3333         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
3334         CHECK(val->result_ok);
3335         return *val->contents.result;
3336 }
3337 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
3338         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
3339         CHECK(!val->result_ok);
3340         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
3341         return err_conv;
3342 }
3343 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
3344         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
3345         ret->datalen = *((uint32_t*)elems);
3346         if (ret->datalen == 0) {
3347                 ret->data = NULL;
3348         } else {
3349                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
3350                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3351                 for (size_t i = 0; i < ret->datalen; i++) {
3352                         uint32_t arr_elem = java_elems[i];
3353                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
3354                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
3355                         ret->data[i] = arr_elem_conv;
3356                 }
3357         }
3358         return (long)ret;
3359 }
3360 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
3361         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
3362 }
3363 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
3364         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3365         CHECK(val->result_ok);
3366         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3367         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3368         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
3369         for (size_t m = 0; m < res_var.datalen; m++) {
3370                 long res_conv_38_ref = (long)(&res_var.data[m]) | 1;
3371                 res_arr_ptr[m] = res_conv_38_ref;
3372         }
3373         return res_arr;
3374 }
3375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
3376         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3377         CHECK(!val->result_ok);
3378         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
3379         return err_conv;
3380 }
3381 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
3382         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3383         switch(obj->tag) {
3384                 case LDKAPIError_APIMisuseError: {
3385                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
3386                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3387                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
3388                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
3389                 }
3390                 case LDKAPIError_FeeRateTooHigh: {
3391                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
3392                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3393                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
3394                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
3395                 }
3396                 case LDKAPIError_RouteError: {
3397                         LDKStr err_str = obj->route_error.err;
3398                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3399                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
3400                 }
3401                 case LDKAPIError_ChannelUnavailable: {
3402                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
3403                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3404                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
3405                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
3406                 }
3407                 case LDKAPIError_MonitorUpdateFailed: {
3408                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
3409                 }
3410                 default: abort();
3411         }
3412 }
3413 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
3414         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3415 }
3416 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
3417         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3418         CHECK(val->result_ok);
3419         return *val->contents.result;
3420 }
3421 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
3422         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3423         CHECK(!val->result_ok);
3424         long err_ref = ((long)&(*val->contents.err)) | 1;
3425         return err_ref;
3426 }
3427 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
3428         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3429         ret->datalen = *((uint32_t*)elems);
3430         if (ret->datalen == 0) {
3431                 ret->data = NULL;
3432         } else {
3433                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3434                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3435                 for (size_t i = 0; i < ret->datalen; i++) {
3436                         uint32_t arr_elem = java_elems[i];
3437                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3438                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3439                         ret->data[i] = arr_elem_conv;
3440                 }
3441         }
3442         return (long)ret;
3443 }
3444 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3445         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3446         for (size_t i = 0; i < ret.datalen; i++) {
3447                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3448         }
3449         return ret;
3450 }
3451 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
3452         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3453         ret->datalen = *((uint32_t*)elems);
3454         if (ret->datalen == 0) {
3455                 ret->data = NULL;
3456         } else {
3457                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3458                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3459                 for (size_t i = 0; i < ret->datalen; i++) {
3460                         uint32_t arr_elem = java_elems[i];
3461                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3462                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3463                         ret->data[i] = arr_elem_conv;
3464                 }
3465         }
3466         return (long)ret;
3467 }
3468 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3469         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3470         for (size_t i = 0; i < ret.datalen; i++) {
3471                 ret.data[i] = APIError_clone(&orig->data[i]);
3472         }
3473         return ret;
3474 }
3475 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
3476         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3477         switch(obj->tag) {
3478                 case LDKPaymentSendFailure_ParameterError: {
3479                         long parameter_error_ref = ((long)&obj->parameter_error) | 1;
3480                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
3481                 }
3482                 case LDKPaymentSendFailure_PathParameterError: {
3483                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3484                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3485                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
3486                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3487                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3488                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3489                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3490                                 path_parameter_error_arr_ptr[w] = (long)path_parameter_error_conv_22_conv;
3491                         }
3492                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
3493                 }
3494                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3495                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3496                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3497                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
3498                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3499                                 long all_failed_retry_safe_conv_10_ref = ((long)&all_failed_retry_safe_var.data[k]) | 1;
3500                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3501                         }
3502                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
3503                 }
3504                 case LDKPaymentSendFailure_PartialFailure: {
3505                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3506                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3507                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
3508                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3509                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3510                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3511                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3512                                 partial_failure_arr_ptr[w] = (long)partial_failure_conv_22_conv;
3513                         }
3514                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
3515                 }
3516                 default: abort();
3517         }
3518 }
3519 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
3520         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3521 }
3522 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
3523         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3524         CHECK(val->result_ok);
3525         return *val->contents.result;
3526 }
3527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
3528         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3529         CHECK(!val->result_ok);
3530         long err_ref = ((long)&(*val->contents.err)) | 1;
3531         return err_ref;
3532 }
3533 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
3534         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3535         ret->datalen = *((uint32_t*)elems);
3536         if (ret->datalen == 0) {
3537                 ret->data = NULL;
3538         } else {
3539                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3540                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3541                 for (size_t i = 0; i < ret->datalen; i++) {
3542                         uint32_t arr_elem = java_elems[i];
3543                         LDKChannelMonitor arr_elem_conv;
3544                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3545                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3546                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3547                         ret->data[i] = arr_elem_conv;
3548                 }
3549         }
3550         return (long)ret;
3551 }
3552 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3553         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3554         for (size_t i = 0; i < ret.datalen; i++) {
3555                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3556         }
3557         return ret;
3558 }
3559 typedef struct LDKWatch_JCalls {
3560         atomic_size_t refcnt;
3561         uint32_t watch_channel_meth;
3562         uint32_t update_channel_meth;
3563         uint32_t release_pending_monitor_events_meth;
3564 } LDKWatch_JCalls;
3565 static void LDKWatch_JCalls_free(void* this_arg) {
3566         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3567         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3568                 js_free(j_calls->watch_channel_meth);
3569                 js_free(j_calls->update_channel_meth);
3570                 js_free(j_calls->release_pending_monitor_events_meth);
3571                 FREE(j_calls);
3572         }
3573 }
3574 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3575         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3576         LDKOutPoint funding_txo_var = funding_txo;
3577         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3578         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3579         long funding_txo_ref = (long)funding_txo_var.inner;
3580         if (funding_txo_var.is_owned) {
3581                 funding_txo_ref |= 1;
3582         }
3583         LDKChannelMonitor monitor_var = monitor;
3584         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         long monitor_ref = (long)monitor_var.inner;
3587         if (monitor_var.is_owned) {
3588                 monitor_ref |= 1;
3589         }
3590         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3591         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3592         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3593         return ret_conv;
3594 }
3595 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3596         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3597         LDKOutPoint funding_txo_var = funding_txo;
3598         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3599         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3600         long funding_txo_ref = (long)funding_txo_var.inner;
3601         if (funding_txo_var.is_owned) {
3602                 funding_txo_ref |= 1;
3603         }
3604         LDKChannelMonitorUpdate update_var = update;
3605         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3606         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3607         long update_ref = (long)update_var.inner;
3608         if (update_var.is_owned) {
3609                 update_ref |= 1;
3610         }
3611         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
3612         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3613         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3614         return ret_conv;
3615 }
3616 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3617         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3618         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
3619         LDKCVec_MonitorEventZ ret_constr;
3620         ret_constr.datalen = *((uint32_t*)ret);
3621         if (ret_constr.datalen > 0)
3622                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3623         else
3624                 ret_constr.data = NULL;
3625         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3626         for (size_t o = 0; o < ret_constr.datalen; o++) {
3627                 uint32_t ret_conv_14 = ret_vals[o];
3628                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3629                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3630                 ret_constr.data[o] = ret_conv_14_conv;
3631         }
3632         return ret_constr;
3633 }
3634 static void* LDKWatch_JCalls_clone(const void* this_arg) {
3635         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3636         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3637         return (void*) this_arg;
3638 }
3639 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
3640         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3641         atomic_init(&calls->refcnt, 1);
3642         //TODO: Assign calls->o from o
3643
3644         LDKWatch ret = {
3645                 .this_arg = (void*) calls,
3646                 .watch_channel = watch_channel_LDKWatch_jcall,
3647                 .update_channel = update_channel_LDKWatch_jcall,
3648                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3649                 .free = LDKWatch_JCalls_free,
3650         };
3651         return ret;
3652 }
3653 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
3654         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3655         *res_ptr = LDKWatch_init(o);
3656         return (long)res_ptr;
3657 }
3658 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
3659         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3660         LDKOutPoint funding_txo_conv;
3661         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3662         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3663         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3664         LDKChannelMonitor monitor_conv;
3665         monitor_conv.inner = (void*)(monitor & (~1));
3666         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3667         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3668         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3669         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3670         return (long)ret_conv;
3671 }
3672
3673 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
3674         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3675         LDKOutPoint funding_txo_conv;
3676         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3677         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3678         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3679         LDKChannelMonitorUpdate update_conv;
3680         update_conv.inner = (void*)(update & (~1));
3681         update_conv.is_owned = (update & 1) || (update == 0);
3682         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3683         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3684         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3685         return (long)ret_conv;
3686 }
3687
3688 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
3689         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3690         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3691         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3692         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3693         for (size_t o = 0; o < ret_var.datalen; o++) {
3694                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3695                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3696                 long ret_conv_14_ref = (long)ret_conv_14_copy;
3697                 ret_arr_ptr[o] = ret_conv_14_ref;
3698         }
3699         FREE(ret_var.data);
3700         return ret_arr;
3701 }
3702
3703 typedef struct LDKBroadcasterInterface_JCalls {
3704         atomic_size_t refcnt;
3705         uint32_t broadcast_transaction_meth;
3706 } LDKBroadcasterInterface_JCalls;
3707 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3708         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3709         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3710                 js_free(j_calls->broadcast_transaction_meth);
3711                 FREE(j_calls);
3712         }
3713 }
3714 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3715         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3716         LDKTransaction tx_var = tx;
3717         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3718         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
3719         Transaction_free(tx_var);
3720         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
3721 }
3722 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
3723         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3724         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3725         return (void*) this_arg;
3726 }
3727 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
3728         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3729         atomic_init(&calls->refcnt, 1);
3730         //TODO: Assign calls->o from o
3731
3732         LDKBroadcasterInterface ret = {
3733                 .this_arg = (void*) calls,
3734                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3735                 .free = LDKBroadcasterInterface_JCalls_free,
3736         };
3737         return ret;
3738 }
3739 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
3740         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3741         *res_ptr = LDKBroadcasterInterface_init(o);
3742         return (long)res_ptr;
3743 }
3744 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
3745         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3746         LDKTransaction tx_ref;
3747         tx_ref.datalen = *((uint32_t*)tx);
3748         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3749         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
3750         tx_ref.data_is_owned = true;
3751         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3752 }
3753
3754 typedef struct LDKKeysInterface_JCalls {
3755         atomic_size_t refcnt;
3756         uint32_t get_node_secret_meth;
3757         uint32_t get_destination_script_meth;
3758         uint32_t get_shutdown_pubkey_meth;
3759         uint32_t get_channel_signer_meth;
3760         uint32_t get_secure_random_bytes_meth;
3761         uint32_t read_chan_signer_meth;
3762 } LDKKeysInterface_JCalls;
3763 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3764         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3765         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3766                 js_free(j_calls->get_node_secret_meth);
3767                 js_free(j_calls->get_destination_script_meth);
3768                 js_free(j_calls->get_shutdown_pubkey_meth);
3769                 js_free(j_calls->get_channel_signer_meth);
3770                 js_free(j_calls->get_secure_random_bytes_meth);
3771                 js_free(j_calls->read_chan_signer_meth);
3772                 FREE(j_calls);
3773         }
3774 }
3775 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3776         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3777         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
3778         LDKSecretKey ret_ref;
3779         CHECK(*((uint32_t*)ret) == 32);
3780         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
3781         return ret_ref;
3782 }
3783 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3784         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3785         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
3786         LDKCVec_u8Z ret_ref;
3787         ret_ref.datalen = *((uint32_t*)ret);
3788         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3789         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3790         return ret_ref;
3791 }
3792 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3793         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3794         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
3795         LDKPublicKey ret_ref;
3796         CHECK(*((uint32_t*)ret) == 33);
3797         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
3798         return ret_ref;
3799 }
3800 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3801         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3802         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3803         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3804         ret_conv = Sign_clone(ret);
3805         return ret_conv;
3806 }
3807 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3808         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3809         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
3810         LDKThirtyTwoBytes ret_ref;
3811         CHECK(*((uint32_t*)ret) == 32);
3812         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
3813         return ret_ref;
3814 }
3815 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3816         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3817         LDKu8slice reader_var = reader;
3818         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3819         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
3820         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
3821         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3822         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
3823         return ret_conv;
3824 }
3825 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
3826         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3827         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3828         return (void*) this_arg;
3829 }
3830 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
3831         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3832         atomic_init(&calls->refcnt, 1);
3833         //TODO: Assign calls->o from o
3834
3835         LDKKeysInterface ret = {
3836                 .this_arg = (void*) calls,
3837                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3838                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3839                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3840                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3841                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3842                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3843                 .free = LDKKeysInterface_JCalls_free,
3844         };
3845         return ret;
3846 }
3847 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
3848         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3849         *res_ptr = LDKKeysInterface_init(o);
3850         return (long)res_ptr;
3851 }
3852 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
3853         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3854         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3855         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
3856         return ret_arr;
3857 }
3858
3859 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
3860         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3861         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3862         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3863         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3864         CVec_u8Z_free(ret_var);
3865         return ret_arr;
3866 }
3867
3868 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
3869         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3870         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3871         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
3872         return ret_arr;
3873 }
3874
3875 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3876         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3877         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3878         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3879         return (long)ret;
3880 }
3881
3882 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
3883         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3884         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3885         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
3886         return ret_arr;
3887 }
3888
3889 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
3890         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3891         LDKu8slice reader_ref;
3892         reader_ref.datalen = *((uint32_t*)reader);
3893         reader_ref.data = (int8_t*)(reader + 4);
3894         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3895         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3896         return (long)ret_conv;
3897 }
3898
3899 typedef struct LDKFeeEstimator_JCalls {
3900         atomic_size_t refcnt;
3901         uint32_t get_est_sat_per_1000_weight_meth;
3902 } LDKFeeEstimator_JCalls;
3903 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3904         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3905         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3906                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
3907                 FREE(j_calls);
3908         }
3909 }
3910 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3911         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3912         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
3913         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3914 }
3915 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
3916         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3917         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3918         return (void*) this_arg;
3919 }
3920 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
3921         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3922         atomic_init(&calls->refcnt, 1);
3923         //TODO: Assign calls->o from o
3924
3925         LDKFeeEstimator ret = {
3926                 .this_arg = (void*) calls,
3927                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3928                 .free = LDKFeeEstimator_JCalls_free,
3929         };
3930         return ret;
3931 }
3932 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
3933         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3934         *res_ptr = LDKFeeEstimator_init(o);
3935         return (long)res_ptr;
3936 }
3937 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
3938         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3939         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
3940         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3941         return ret_val;
3942 }
3943
3944 typedef struct LDKLogger_JCalls {
3945         atomic_size_t refcnt;
3946         uint32_t log_meth;
3947 } LDKLogger_JCalls;
3948 static void LDKLogger_JCalls_free(void* this_arg) {
3949         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3950         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3951                 js_free(j_calls->log_meth);
3952                 FREE(j_calls);
3953         }
3954 }
3955 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3956         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3957         const char* record_str = record;
3958         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
3959         js_invoke_function_1(j_calls->log_meth, record_conv);
3960 }
3961 static void* LDKLogger_JCalls_clone(const void* this_arg) {
3962         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3963         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3964         return (void*) this_arg;
3965 }
3966 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
3967         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3968         atomic_init(&calls->refcnt, 1);
3969         //TODO: Assign calls->o from o
3970
3971         LDKLogger ret = {
3972                 .this_arg = (void*) calls,
3973                 .log = log_LDKLogger_jcall,
3974                 .free = LDKLogger_JCalls_free,
3975         };
3976         return ret;
3977 }
3978 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
3979         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3980         *res_ptr = LDKLogger_init(o);
3981         return (long)res_ptr;
3982 }
3983 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
3984         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3985         LDKThirtyTwoBytes a_ref;
3986         CHECK(*((uint32_t*)a) == 32);
3987         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3988         ret->a = a_ref;
3989         LDKChannelManager b_conv;
3990         b_conv.inner = (void*)(b & (~1));
3991         b_conv.is_owned = (b & 1) || (b == 0);
3992         // Warning: we need a move here but no clone is available for LDKChannelManager
3993         ret->b = b_conv;
3994         return (long)ret;
3995 }
3996 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
3997         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
3998         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3999         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
4000         return a_arr;
4001 }
4002 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
4003         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4004         LDKChannelManager b_var = tuple->b;
4005         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4006         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4007         long b_ref = (long)b_var.inner & ~1;
4008         return b_ref;
4009 }
4010 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
4011         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4012 }
4013 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
4014         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4015         CHECK(val->result_ok);
4016         long res_ref = (long)(&(*val->contents.result)) | 1;
4017         return res_ref;
4018 }
4019 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
4020         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4021         CHECK(!val->result_ok);
4022         LDKDecodeError err_var = (*val->contents.err);
4023         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         long err_ref = (long)err_var.inner & ~1;
4026         return err_ref;
4027 }
4028 typedef struct LDKMessageSendEventsProvider_JCalls {
4029         atomic_size_t refcnt;
4030         uint32_t get_and_clear_pending_msg_events_meth;
4031 } LDKMessageSendEventsProvider_JCalls;
4032 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4033         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4034         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4035                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4036                 FREE(j_calls);
4037         }
4038 }
4039 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4040         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4041         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4042         LDKCVec_MessageSendEventZ ret_constr;
4043         ret_constr.datalen = *((uint32_t*)ret);
4044         if (ret_constr.datalen > 0)
4045                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4046         else
4047                 ret_constr.data = NULL;
4048         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4049         for (size_t s = 0; s < ret_constr.datalen; s++) {
4050                 uint32_t ret_conv_18 = ret_vals[s];
4051                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4052                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4053                 ret_constr.data[s] = ret_conv_18_conv;
4054         }
4055         return ret_constr;
4056 }
4057 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4058         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4059         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4060         return (void*) this_arg;
4061 }
4062 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4063         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4064         atomic_init(&calls->refcnt, 1);
4065         //TODO: Assign calls->o from o
4066
4067         LDKMessageSendEventsProvider ret = {
4068                 .this_arg = (void*) calls,
4069                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4070                 .free = LDKMessageSendEventsProvider_JCalls_free,
4071         };
4072         return ret;
4073 }
4074 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4075         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4076         *res_ptr = LDKMessageSendEventsProvider_init(o);
4077         return (long)res_ptr;
4078 }
4079 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4080         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4081         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4082         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4083         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4084         for (size_t s = 0; s < ret_var.datalen; s++) {
4085                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4086                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4087                 long ret_conv_18_ref = (long)ret_conv_18_copy;
4088                 ret_arr_ptr[s] = ret_conv_18_ref;
4089         }
4090         FREE(ret_var.data);
4091         return ret_arr;
4092 }
4093
4094 typedef struct LDKEventsProvider_JCalls {
4095         atomic_size_t refcnt;
4096         uint32_t get_and_clear_pending_events_meth;
4097 } LDKEventsProvider_JCalls;
4098 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4099         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4100         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4101                 js_free(j_calls->get_and_clear_pending_events_meth);
4102                 FREE(j_calls);
4103         }
4104 }
4105 LDKCVec_EventZ get_and_clear_pending_events_LDKEventsProvider_jcall(const void* this_arg) {
4106         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4107         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
4108         LDKCVec_EventZ ret_constr;
4109         ret_constr.datalen = *((uint32_t*)ret);
4110         if (ret_constr.datalen > 0)
4111                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4112         else
4113                 ret_constr.data = NULL;
4114         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4115         for (size_t h = 0; h < ret_constr.datalen; h++) {
4116                 uint32_t ret_conv_7 = ret_vals[h];
4117                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
4118                 ret_conv_7_conv = Event_clone((LDKEvent*)(((uint64_t)ret_conv_7) & ~1));
4119                 ret_constr.data[h] = ret_conv_7_conv;
4120         }
4121         return ret_constr;
4122 }
4123 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4124         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4125         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4126         return (void*) this_arg;
4127 }
4128 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4129         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4130         atomic_init(&calls->refcnt, 1);
4131         //TODO: Assign calls->o from o
4132
4133         LDKEventsProvider ret = {
4134                 .this_arg = (void*) calls,
4135                 .get_and_clear_pending_events = get_and_clear_pending_events_LDKEventsProvider_jcall,
4136                 .free = LDKEventsProvider_JCalls_free,
4137         };
4138         return ret;
4139 }
4140 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4141         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4142         *res_ptr = LDKEventsProvider_init(o);
4143         return (long)res_ptr;
4144 }
4145 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
4146         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4147         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
4148         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4149         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4150         for (size_t h = 0; h < ret_var.datalen; h++) {
4151                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4152                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
4153                 long ret_conv_7_ref = (long)ret_conv_7_copy;
4154                 ret_arr_ptr[h] = ret_conv_7_ref;
4155         }
4156         FREE(ret_var.data);
4157         return ret_arr;
4158 }
4159
4160 typedef struct LDKAccess_JCalls {
4161         atomic_size_t refcnt;
4162         uint32_t get_utxo_meth;
4163 } LDKAccess_JCalls;
4164 static void LDKAccess_JCalls_free(void* this_arg) {
4165         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4166         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4167                 js_free(j_calls->get_utxo_meth);
4168                 FREE(j_calls);
4169         }
4170 }
4171 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4172         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4173         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4174         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4175         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4176         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4177         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4178         return ret_conv;
4179 }
4180 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4181         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4182         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4183         return (void*) this_arg;
4184 }
4185 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4186         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4187         atomic_init(&calls->refcnt, 1);
4188         //TODO: Assign calls->o from o
4189
4190         LDKAccess ret = {
4191                 .this_arg = (void*) calls,
4192                 .get_utxo = get_utxo_LDKAccess_jcall,
4193                 .free = LDKAccess_JCalls_free,
4194         };
4195         return ret;
4196 }
4197 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4198         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4199         *res_ptr = LDKAccess_init(o);
4200         return (long)res_ptr;
4201 }
4202 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4203         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4204         unsigned char genesis_hash_arr[32];
4205         CHECK(*((uint32_t*)genesis_hash) == 32);
4206         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4207         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4208         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4209         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4210         return (long)ret_conv;
4211 }
4212
4213 typedef struct LDKListen_JCalls {
4214         atomic_size_t refcnt;
4215         uint32_t block_connected_meth;
4216         uint32_t block_disconnected_meth;
4217 } LDKListen_JCalls;
4218 static void LDKListen_JCalls_free(void* this_arg) {
4219         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4220         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4221                 js_free(j_calls->block_connected_meth);
4222                 js_free(j_calls->block_disconnected_meth);
4223                 FREE(j_calls);
4224         }
4225 }
4226 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4227         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4228         LDKu8slice block_var = block;
4229         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4230         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4231         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4232 }
4233 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4234         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4235         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4236         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4237         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4238 }
4239 static void* LDKListen_JCalls_clone(const void* this_arg) {
4240         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4241         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4242         return (void*) this_arg;
4243 }
4244 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4245         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4246         atomic_init(&calls->refcnt, 1);
4247         //TODO: Assign calls->o from o
4248
4249         LDKListen ret = {
4250                 .this_arg = (void*) calls,
4251                 .block_connected = block_connected_LDKListen_jcall,
4252                 .block_disconnected = block_disconnected_LDKListen_jcall,
4253                 .free = LDKListen_JCalls_free,
4254         };
4255         return ret;
4256 }
4257 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4258         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4259         *res_ptr = LDKListen_init(o);
4260         return (long)res_ptr;
4261 }
4262 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4263         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4264         LDKu8slice block_ref;
4265         block_ref.datalen = *((uint32_t*)block);
4266         block_ref.data = (int8_t*)(block + 4);
4267         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4268 }
4269
4270 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4271         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4272         unsigned char header_arr[80];
4273         CHECK(*((uint32_t*)header) == 80);
4274         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4275         unsigned char (*header_ref)[80] = &header_arr;
4276         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4277 }
4278
4279 typedef struct LDKFilter_JCalls {
4280         atomic_size_t refcnt;
4281         uint32_t register_tx_meth;
4282         uint32_t register_output_meth;
4283 } LDKFilter_JCalls;
4284 static void LDKFilter_JCalls_free(void* this_arg) {
4285         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4286         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4287                 js_free(j_calls->register_tx_meth);
4288                 js_free(j_calls->register_output_meth);
4289                 FREE(j_calls);
4290         }
4291 }
4292 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4293         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4294         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4295         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4296         LDKu8slice script_pubkey_var = script_pubkey;
4297         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4298         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4299         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4300 }
4301 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
4302         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4303         LDKWatchedOutput output_var = output;
4304         CHECK((((long)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4305         CHECK((((long)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4306         long output_ref = (long)output_var.inner;
4307         if (output_var.is_owned) {
4308                 output_ref |= 1;
4309         }
4310         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
4311         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
4312         // Warning: we may need a move here but no clone is available for LDKCOption_C2Tuple_usizeTransactionZZ
4313         return ret_conv;
4314 }
4315 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4316         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4317         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4318         return (void*) this_arg;
4319 }
4320 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
4321         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4322         atomic_init(&calls->refcnt, 1);
4323         //TODO: Assign calls->o from o
4324
4325         LDKFilter ret = {
4326                 .this_arg = (void*) calls,
4327                 .register_tx = register_tx_LDKFilter_jcall,
4328                 .register_output = register_output_LDKFilter_jcall,
4329                 .free = LDKFilter_JCalls_free,
4330         };
4331         return ret;
4332 }
4333 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
4334         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4335         *res_ptr = LDKFilter_init(o);
4336         return (long)res_ptr;
4337 }
4338 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
4339         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4340         unsigned char txid_arr[32];
4341         CHECK(*((uint32_t*)txid) == 32);
4342         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
4343         unsigned char (*txid_ref)[32] = &txid_arr;
4344         LDKu8slice script_pubkey_ref;
4345         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4346         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4347         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4348 }
4349
4350 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
4351         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4352         LDKWatchedOutput output_conv;
4353         output_conv.inner = (void*)(output & (~1));
4354         output_conv.is_owned = (output & 1) || (output == 0);
4355         // Warning: we need a move here but no clone is available for LDKWatchedOutput
4356         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
4357         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
4358         long ret_ref = (long)ret_copy;
4359         return ret_ref;
4360 }
4361
4362 typedef struct LDKPersist_JCalls {
4363         atomic_size_t refcnt;
4364         uint32_t persist_new_channel_meth;
4365         uint32_t update_persisted_channel_meth;
4366 } LDKPersist_JCalls;
4367 static void LDKPersist_JCalls_free(void* this_arg) {
4368         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4369         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4370                 js_free(j_calls->persist_new_channel_meth);
4371                 js_free(j_calls->update_persisted_channel_meth);
4372                 FREE(j_calls);
4373         }
4374 }
4375 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4376         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4377         LDKOutPoint id_var = id;
4378         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4379         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4380         long id_ref = (long)id_var.inner;
4381         if (id_var.is_owned) {
4382                 id_ref |= 1;
4383         }
4384         LDKChannelMonitor data_var = *data;
4385         data_var = ChannelMonitor_clone(data);
4386         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4387         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4388         long data_ref = (long)data_var.inner;
4389         if (data_var.is_owned) {
4390                 data_ref |= 1;
4391         }
4392         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
4393         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4394         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4395         return ret_conv;
4396 }
4397 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
4398         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4399         LDKOutPoint id_var = id;
4400         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4401         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4402         long id_ref = (long)id_var.inner;
4403         if (id_var.is_owned) {
4404                 id_ref |= 1;
4405         }
4406         LDKChannelMonitorUpdate update_var = *update;
4407         update_var = ChannelMonitorUpdate_clone(update);
4408         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4409         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4410         long update_ref = (long)update_var.inner;
4411         if (update_var.is_owned) {
4412                 update_ref |= 1;
4413         }
4414         LDKChannelMonitor data_var = *data;
4415         data_var = ChannelMonitor_clone(data);
4416         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4417         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4418         long data_ref = (long)data_var.inner;
4419         if (data_var.is_owned) {
4420                 data_ref |= 1;
4421         }
4422         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
4423         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4424         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
4425         return ret_conv;
4426 }
4427 static void* LDKPersist_JCalls_clone(const void* this_arg) {
4428         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4429         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4430         return (void*) this_arg;
4431 }
4432 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
4433         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
4434         atomic_init(&calls->refcnt, 1);
4435         //TODO: Assign calls->o from o
4436
4437         LDKPersist ret = {
4438                 .this_arg = (void*) calls,
4439                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
4440                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
4441                 .free = LDKPersist_JCalls_free,
4442         };
4443         return ret;
4444 }
4445 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
4446         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
4447         *res_ptr = LDKPersist_init(o);
4448         return (long)res_ptr;
4449 }
4450 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
4451         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4452         LDKOutPoint id_conv;
4453         id_conv.inner = (void*)(id & (~1));
4454         id_conv.is_owned = (id & 1) || (id == 0);
4455         id_conv = OutPoint_clone(&id_conv);
4456         LDKChannelMonitor data_conv;
4457         data_conv.inner = (void*)(data & (~1));
4458         data_conv.is_owned = false;
4459         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4460         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
4461         return (long)ret_conv;
4462 }
4463
4464 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
4465         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4466         LDKOutPoint id_conv;
4467         id_conv.inner = (void*)(id & (~1));
4468         id_conv.is_owned = (id & 1) || (id == 0);
4469         id_conv = OutPoint_clone(&id_conv);
4470         LDKChannelMonitorUpdate update_conv;
4471         update_conv.inner = (void*)(update & (~1));
4472         update_conv.is_owned = false;
4473         LDKChannelMonitor data_conv;
4474         data_conv.inner = (void*)(data & (~1));
4475         data_conv.is_owned = false;
4476         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4477         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
4478         return (long)ret_conv;
4479 }
4480
4481 typedef struct LDKChannelMessageHandler_JCalls {
4482         atomic_size_t refcnt;
4483         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4484         uint32_t handle_open_channel_meth;
4485         uint32_t handle_accept_channel_meth;
4486         uint32_t handle_funding_created_meth;
4487         uint32_t handle_funding_signed_meth;
4488         uint32_t handle_funding_locked_meth;
4489         uint32_t handle_shutdown_meth;
4490         uint32_t handle_closing_signed_meth;
4491         uint32_t handle_update_add_htlc_meth;
4492         uint32_t handle_update_fulfill_htlc_meth;
4493         uint32_t handle_update_fail_htlc_meth;
4494         uint32_t handle_update_fail_malformed_htlc_meth;
4495         uint32_t handle_commitment_signed_meth;
4496         uint32_t handle_revoke_and_ack_meth;
4497         uint32_t handle_update_fee_meth;
4498         uint32_t handle_announcement_signatures_meth;
4499         uint32_t peer_disconnected_meth;
4500         uint32_t peer_connected_meth;
4501         uint32_t handle_channel_reestablish_meth;
4502         uint32_t handle_channel_update_meth;
4503         uint32_t handle_error_meth;
4504 } LDKChannelMessageHandler_JCalls;
4505 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
4506         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4507         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4508                 js_free(j_calls->handle_open_channel_meth);
4509                 js_free(j_calls->handle_accept_channel_meth);
4510                 js_free(j_calls->handle_funding_created_meth);
4511                 js_free(j_calls->handle_funding_signed_meth);
4512                 js_free(j_calls->handle_funding_locked_meth);
4513                 js_free(j_calls->handle_shutdown_meth);
4514                 js_free(j_calls->handle_closing_signed_meth);
4515                 js_free(j_calls->handle_update_add_htlc_meth);
4516                 js_free(j_calls->handle_update_fulfill_htlc_meth);
4517                 js_free(j_calls->handle_update_fail_htlc_meth);
4518                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
4519                 js_free(j_calls->handle_commitment_signed_meth);
4520                 js_free(j_calls->handle_revoke_and_ack_meth);
4521                 js_free(j_calls->handle_update_fee_meth);
4522                 js_free(j_calls->handle_announcement_signatures_meth);
4523                 js_free(j_calls->peer_disconnected_meth);
4524                 js_free(j_calls->peer_connected_meth);
4525                 js_free(j_calls->handle_channel_reestablish_meth);
4526                 js_free(j_calls->handle_channel_update_meth);
4527                 js_free(j_calls->handle_error_meth);
4528                 FREE(j_calls);
4529         }
4530 }
4531 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
4532         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4533         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4534         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4535         LDKInitFeatures their_features_var = their_features;
4536         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4537         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4538         long their_features_ref = (long)their_features_var.inner;
4539         if (their_features_var.is_owned) {
4540                 their_features_ref |= 1;
4541         }
4542         LDKOpenChannel msg_var = *msg;
4543         msg_var = OpenChannel_clone(msg);
4544         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4545         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4546         long msg_ref = (long)msg_var.inner;
4547         if (msg_var.is_owned) {
4548                 msg_ref |= 1;
4549         }
4550         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4551 }
4552 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
4553         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4554         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4555         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4556         LDKInitFeatures their_features_var = their_features;
4557         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4558         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4559         long their_features_ref = (long)their_features_var.inner;
4560         if (their_features_var.is_owned) {
4561                 their_features_ref |= 1;
4562         }
4563         LDKAcceptChannel msg_var = *msg;
4564         msg_var = AcceptChannel_clone(msg);
4565         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4566         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4567         long msg_ref = (long)msg_var.inner;
4568         if (msg_var.is_owned) {
4569                 msg_ref |= 1;
4570         }
4571         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4572 }
4573 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
4574         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4575         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4576         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4577         LDKFundingCreated msg_var = *msg;
4578         msg_var = FundingCreated_clone(msg);
4579         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4580         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4581         long msg_ref = (long)msg_var.inner;
4582         if (msg_var.is_owned) {
4583                 msg_ref |= 1;
4584         }
4585         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
4586 }
4587 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
4588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4589         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4590         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4591         LDKFundingSigned msg_var = *msg;
4592         msg_var = FundingSigned_clone(msg);
4593         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4594         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4595         long msg_ref = (long)msg_var.inner;
4596         if (msg_var.is_owned) {
4597                 msg_ref |= 1;
4598         }
4599         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
4600 }
4601 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
4602         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4603         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4604         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4605         LDKFundingLocked msg_var = *msg;
4606         msg_var = FundingLocked_clone(msg);
4607         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4608         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4609         long msg_ref = (long)msg_var.inner;
4610         if (msg_var.is_owned) {
4611                 msg_ref |= 1;
4612         }
4613         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
4614 }
4615 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
4616         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4617         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4618         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4619         LDKInitFeatures their_features_var = *their_features;
4620         their_features_var = InitFeatures_clone(their_features);
4621         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4622         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4623         long their_features_ref = (long)their_features_var.inner;
4624         if (their_features_var.is_owned) {
4625                 their_features_ref |= 1;
4626         }
4627         LDKShutdown msg_var = *msg;
4628         msg_var = Shutdown_clone(msg);
4629         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4630         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4631         long msg_ref = (long)msg_var.inner;
4632         if (msg_var.is_owned) {
4633                 msg_ref |= 1;
4634         }
4635         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
4636 }
4637 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
4638         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4639         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4640         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4641         LDKClosingSigned msg_var = *msg;
4642         msg_var = ClosingSigned_clone(msg);
4643         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4644         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4645         long msg_ref = (long)msg_var.inner;
4646         if (msg_var.is_owned) {
4647                 msg_ref |= 1;
4648         }
4649         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
4650 }
4651 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
4652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4653         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4654         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4655         LDKUpdateAddHTLC msg_var = *msg;
4656         msg_var = UpdateAddHTLC_clone(msg);
4657         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4658         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4659         long msg_ref = (long)msg_var.inner;
4660         if (msg_var.is_owned) {
4661                 msg_ref |= 1;
4662         }
4663         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
4664 }
4665 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
4666         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4667         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4668         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4669         LDKUpdateFulfillHTLC msg_var = *msg;
4670         msg_var = UpdateFulfillHTLC_clone(msg);
4671         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4672         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4673         long msg_ref = (long)msg_var.inner;
4674         if (msg_var.is_owned) {
4675                 msg_ref |= 1;
4676         }
4677         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
4678 }
4679 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
4680         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4681         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4682         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4683         LDKUpdateFailHTLC msg_var = *msg;
4684         msg_var = UpdateFailHTLC_clone(msg);
4685         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4686         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4687         long msg_ref = (long)msg_var.inner;
4688         if (msg_var.is_owned) {
4689                 msg_ref |= 1;
4690         }
4691         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
4692 }
4693 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
4694         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4695         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4696         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4697         LDKUpdateFailMalformedHTLC msg_var = *msg;
4698         msg_var = UpdateFailMalformedHTLC_clone(msg);
4699         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4700         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4701         long msg_ref = (long)msg_var.inner;
4702         if (msg_var.is_owned) {
4703                 msg_ref |= 1;
4704         }
4705         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
4706 }
4707 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
4708         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4709         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4710         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4711         LDKCommitmentSigned msg_var = *msg;
4712         msg_var = CommitmentSigned_clone(msg);
4713         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4714         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4715         long msg_ref = (long)msg_var.inner;
4716         if (msg_var.is_owned) {
4717                 msg_ref |= 1;
4718         }
4719         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
4720 }
4721 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
4722         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4723         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4724         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4725         LDKRevokeAndACK msg_var = *msg;
4726         msg_var = RevokeAndACK_clone(msg);
4727         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4728         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4729         long msg_ref = (long)msg_var.inner;
4730         if (msg_var.is_owned) {
4731                 msg_ref |= 1;
4732         }
4733         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
4734 }
4735 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
4736         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4737         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4738         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4739         LDKUpdateFee msg_var = *msg;
4740         msg_var = UpdateFee_clone(msg);
4741         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4742         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4743         long msg_ref = (long)msg_var.inner;
4744         if (msg_var.is_owned) {
4745                 msg_ref |= 1;
4746         }
4747         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
4748 }
4749 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
4750         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4751         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4752         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4753         LDKAnnouncementSignatures msg_var = *msg;
4754         msg_var = AnnouncementSignatures_clone(msg);
4755         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4756         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4757         long msg_ref = (long)msg_var.inner;
4758         if (msg_var.is_owned) {
4759                 msg_ref |= 1;
4760         }
4761         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
4762 }
4763 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
4764         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4765         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4766         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4767         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
4768 }
4769 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
4770         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4771         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4772         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4773         LDKInit msg_var = *msg;
4774         msg_var = Init_clone(msg);
4775         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4776         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4777         long msg_ref = (long)msg_var.inner;
4778         if (msg_var.is_owned) {
4779                 msg_ref |= 1;
4780         }
4781         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
4782 }
4783 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
4784         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4785         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4786         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4787         LDKChannelReestablish msg_var = *msg;
4788         msg_var = ChannelReestablish_clone(msg);
4789         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4790         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4791         long msg_ref = (long)msg_var.inner;
4792         if (msg_var.is_owned) {
4793                 msg_ref |= 1;
4794         }
4795         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
4796 }
4797 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
4798         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4799         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4800         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4801         LDKChannelUpdate msg_var = *msg;
4802         msg_var = ChannelUpdate_clone(msg);
4803         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4804         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4805         long msg_ref = (long)msg_var.inner;
4806         if (msg_var.is_owned) {
4807                 msg_ref |= 1;
4808         }
4809         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
4810 }
4811 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
4812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4813         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4814         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4815         LDKErrorMessage msg_var = *msg;
4816         msg_var = ErrorMessage_clone(msg);
4817         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4818         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4819         long msg_ref = (long)msg_var.inner;
4820         if (msg_var.is_owned) {
4821                 msg_ref |= 1;
4822         }
4823         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
4824 }
4825 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
4826         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4827         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4828         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4829         return (void*) this_arg;
4830 }
4831 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4832         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
4833         atomic_init(&calls->refcnt, 1);
4834         //TODO: Assign calls->o from o
4835
4836         LDKChannelMessageHandler ret = {
4837                 .this_arg = (void*) calls,
4838                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
4839                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
4840                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
4841                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
4842                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
4843                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
4844                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
4845                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
4846                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
4847                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
4848                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
4849                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
4850                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
4851                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
4852                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
4853                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
4854                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
4855                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
4856                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
4857                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
4858                 .free = LDKChannelMessageHandler_JCalls_free,
4859                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4860         };
4861         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4862         return ret;
4863 }
4864 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4865         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
4866         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
4867         return (long)res_ptr;
4868 }
4869 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) {
4870         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4871         LDKPublicKey their_node_id_ref;
4872         CHECK(*((uint32_t*)their_node_id) == 33);
4873         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4874         LDKInitFeatures their_features_conv;
4875         their_features_conv.inner = (void*)(their_features & (~1));
4876         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4877         their_features_conv = InitFeatures_clone(&their_features_conv);
4878         LDKOpenChannel msg_conv;
4879         msg_conv.inner = (void*)(msg & (~1));
4880         msg_conv.is_owned = false;
4881         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4882 }
4883
4884 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) {
4885         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4886         LDKPublicKey their_node_id_ref;
4887         CHECK(*((uint32_t*)their_node_id) == 33);
4888         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4889         LDKInitFeatures their_features_conv;
4890         their_features_conv.inner = (void*)(their_features & (~1));
4891         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4892         their_features_conv = InitFeatures_clone(&their_features_conv);
4893         LDKAcceptChannel msg_conv;
4894         msg_conv.inner = (void*)(msg & (~1));
4895         msg_conv.is_owned = false;
4896         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4897 }
4898
4899 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4901         LDKPublicKey their_node_id_ref;
4902         CHECK(*((uint32_t*)their_node_id) == 33);
4903         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4904         LDKFundingCreated msg_conv;
4905         msg_conv.inner = (void*)(msg & (~1));
4906         msg_conv.is_owned = false;
4907         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4908 }
4909
4910 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4912         LDKPublicKey their_node_id_ref;
4913         CHECK(*((uint32_t*)their_node_id) == 33);
4914         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4915         LDKFundingSigned msg_conv;
4916         msg_conv.inner = (void*)(msg & (~1));
4917         msg_conv.is_owned = false;
4918         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4919 }
4920
4921 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4922         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4923         LDKPublicKey their_node_id_ref;
4924         CHECK(*((uint32_t*)their_node_id) == 33);
4925         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4926         LDKFundingLocked msg_conv;
4927         msg_conv.inner = (void*)(msg & (~1));
4928         msg_conv.is_owned = false;
4929         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4930 }
4931
4932 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4933         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4934         LDKPublicKey their_node_id_ref;
4935         CHECK(*((uint32_t*)their_node_id) == 33);
4936         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4937         LDKInitFeatures their_features_conv;
4938         their_features_conv.inner = (void*)(their_features & (~1));
4939         their_features_conv.is_owned = false;
4940         LDKShutdown msg_conv;
4941         msg_conv.inner = (void*)(msg & (~1));
4942         msg_conv.is_owned = false;
4943         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
4944 }
4945
4946 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4947         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4948         LDKPublicKey their_node_id_ref;
4949         CHECK(*((uint32_t*)their_node_id) == 33);
4950         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4951         LDKClosingSigned msg_conv;
4952         msg_conv.inner = (void*)(msg & (~1));
4953         msg_conv.is_owned = false;
4954         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4955 }
4956
4957 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4958         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4959         LDKPublicKey their_node_id_ref;
4960         CHECK(*((uint32_t*)their_node_id) == 33);
4961         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4962         LDKUpdateAddHTLC msg_conv;
4963         msg_conv.inner = (void*)(msg & (~1));
4964         msg_conv.is_owned = false;
4965         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4966 }
4967
4968 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4969         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4970         LDKPublicKey their_node_id_ref;
4971         CHECK(*((uint32_t*)their_node_id) == 33);
4972         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4973         LDKUpdateFulfillHTLC msg_conv;
4974         msg_conv.inner = (void*)(msg & (~1));
4975         msg_conv.is_owned = false;
4976         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4977 }
4978
4979 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4980         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4981         LDKPublicKey their_node_id_ref;
4982         CHECK(*((uint32_t*)their_node_id) == 33);
4983         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4984         LDKUpdateFailHTLC msg_conv;
4985         msg_conv.inner = (void*)(msg & (~1));
4986         msg_conv.is_owned = false;
4987         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4988 }
4989
4990 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4991         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4992         LDKPublicKey their_node_id_ref;
4993         CHECK(*((uint32_t*)their_node_id) == 33);
4994         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4995         LDKUpdateFailMalformedHTLC msg_conv;
4996         msg_conv.inner = (void*)(msg & (~1));
4997         msg_conv.is_owned = false;
4998         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4999 }
5000
5001 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5002         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5003         LDKPublicKey their_node_id_ref;
5004         CHECK(*((uint32_t*)their_node_id) == 33);
5005         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5006         LDKCommitmentSigned msg_conv;
5007         msg_conv.inner = (void*)(msg & (~1));
5008         msg_conv.is_owned = false;
5009         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5010 }
5011
5012 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5013         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5014         LDKPublicKey their_node_id_ref;
5015         CHECK(*((uint32_t*)their_node_id) == 33);
5016         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5017         LDKRevokeAndACK msg_conv;
5018         msg_conv.inner = (void*)(msg & (~1));
5019         msg_conv.is_owned = false;
5020         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5021 }
5022
5023 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5024         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5025         LDKPublicKey their_node_id_ref;
5026         CHECK(*((uint32_t*)their_node_id) == 33);
5027         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5028         LDKUpdateFee msg_conv;
5029         msg_conv.inner = (void*)(msg & (~1));
5030         msg_conv.is_owned = false;
5031         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5032 }
5033
5034 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5035         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5036         LDKPublicKey their_node_id_ref;
5037         CHECK(*((uint32_t*)their_node_id) == 33);
5038         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5039         LDKAnnouncementSignatures msg_conv;
5040         msg_conv.inner = (void*)(msg & (~1));
5041         msg_conv.is_owned = false;
5042         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5043 }
5044
5045 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5046         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5047         LDKPublicKey their_node_id_ref;
5048         CHECK(*((uint32_t*)their_node_id) == 33);
5049         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5050         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5051 }
5052
5053 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5054         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5055         LDKPublicKey their_node_id_ref;
5056         CHECK(*((uint32_t*)their_node_id) == 33);
5057         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5058         LDKInit msg_conv;
5059         msg_conv.inner = (void*)(msg & (~1));
5060         msg_conv.is_owned = false;
5061         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5062 }
5063
5064 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5065         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5066         LDKPublicKey their_node_id_ref;
5067         CHECK(*((uint32_t*)their_node_id) == 33);
5068         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5069         LDKChannelReestablish msg_conv;
5070         msg_conv.inner = (void*)(msg & (~1));
5071         msg_conv.is_owned = false;
5072         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5073 }
5074
5075 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5076         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5077         LDKPublicKey their_node_id_ref;
5078         CHECK(*((uint32_t*)their_node_id) == 33);
5079         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5080         LDKChannelUpdate msg_conv;
5081         msg_conv.inner = (void*)(msg & (~1));
5082         msg_conv.is_owned = false;
5083         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5084 }
5085
5086 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5087         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5088         LDKPublicKey their_node_id_ref;
5089         CHECK(*((uint32_t*)their_node_id) == 33);
5090         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5091         LDKErrorMessage msg_conv;
5092         msg_conv.inner = (void*)(msg & (~1));
5093         msg_conv.is_owned = false;
5094         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5095 }
5096
5097 typedef struct LDKRoutingMessageHandler_JCalls {
5098         atomic_size_t refcnt;
5099         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5100         uint32_t handle_node_announcement_meth;
5101         uint32_t handle_channel_announcement_meth;
5102         uint32_t handle_channel_update_meth;
5103         uint32_t handle_htlc_fail_channel_update_meth;
5104         uint32_t get_next_channel_announcements_meth;
5105         uint32_t get_next_node_announcements_meth;
5106         uint32_t sync_routing_table_meth;
5107         uint32_t handle_reply_channel_range_meth;
5108         uint32_t handle_reply_short_channel_ids_end_meth;
5109         uint32_t handle_query_channel_range_meth;
5110         uint32_t handle_query_short_channel_ids_meth;
5111 } LDKRoutingMessageHandler_JCalls;
5112 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5113         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5114         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5115                 js_free(j_calls->handle_node_announcement_meth);
5116                 js_free(j_calls->handle_channel_announcement_meth);
5117                 js_free(j_calls->handle_channel_update_meth);
5118                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
5119                 js_free(j_calls->get_next_channel_announcements_meth);
5120                 js_free(j_calls->get_next_node_announcements_meth);
5121                 js_free(j_calls->sync_routing_table_meth);
5122                 js_free(j_calls->handle_reply_channel_range_meth);
5123                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
5124                 js_free(j_calls->handle_query_channel_range_meth);
5125                 js_free(j_calls->handle_query_short_channel_ids_meth);
5126                 FREE(j_calls);
5127         }
5128 }
5129 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5130         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5131         LDKNodeAnnouncement msg_var = *msg;
5132         msg_var = NodeAnnouncement_clone(msg);
5133         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5134         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5135         long msg_ref = (long)msg_var.inner;
5136         if (msg_var.is_owned) {
5137                 msg_ref |= 1;
5138         }
5139         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5140         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5141         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5142         return ret_conv;
5143 }
5144 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5145         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5146         LDKChannelAnnouncement msg_var = *msg;
5147         msg_var = ChannelAnnouncement_clone(msg);
5148         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5149         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5150         long msg_ref = (long)msg_var.inner;
5151         if (msg_var.is_owned) {
5152                 msg_ref |= 1;
5153         }
5154         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5155         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5156         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5157         return ret_conv;
5158 }
5159 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5160         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5161         LDKChannelUpdate msg_var = *msg;
5162         msg_var = ChannelUpdate_clone(msg);
5163         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5164         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5165         long msg_ref = (long)msg_var.inner;
5166         if (msg_var.is_owned) {
5167                 msg_ref |= 1;
5168         }
5169         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5170         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5171         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5172         return ret_conv;
5173 }
5174 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5175         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5176         long ret_update = (long)update;
5177         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5178 }
5179 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5180         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5181         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5182         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5183         ret_constr.datalen = *((uint32_t*)ret);
5184         if (ret_constr.datalen > 0)
5185                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5186         else
5187                 ret_constr.data = NULL;
5188         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5189         for (size_t l = 0; l < ret_constr.datalen; l++) {
5190                 uint32_t ret_conv_63 = ret_vals[l];
5191                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5192                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5193                 ret_constr.data[l] = ret_conv_63_conv;
5194         }
5195         return ret_constr;
5196 }
5197 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5198         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5199         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5200         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5201         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5202         LDKCVec_NodeAnnouncementZ ret_constr;
5203         ret_constr.datalen = *((uint32_t*)ret);
5204         if (ret_constr.datalen > 0)
5205                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5206         else
5207                 ret_constr.data = NULL;
5208         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5209         for (size_t s = 0; s < ret_constr.datalen; s++) {
5210                 uint32_t ret_conv_18 = ret_vals[s];
5211                 LDKNodeAnnouncement ret_conv_18_conv;
5212                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5213                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5214                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5215                 ret_constr.data[s] = ret_conv_18_conv;
5216         }
5217         return ret_constr;
5218 }
5219 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5220         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5221         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5222         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5223         LDKInit init_var = *init;
5224         init_var = Init_clone(init);
5225         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         long init_ref = (long)init_var.inner;
5228         if (init_var.is_owned) {
5229                 init_ref |= 1;
5230         }
5231         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5232 }
5233 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5234         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5235         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5236         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5237         LDKReplyChannelRange msg_var = msg;
5238         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5239         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5240         long msg_ref = (long)msg_var.inner;
5241         if (msg_var.is_owned) {
5242                 msg_ref |= 1;
5243         }
5244         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
5245         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5246         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5247         return ret_conv;
5248 }
5249 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5250         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5251         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5252         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5253         LDKReplyShortChannelIdsEnd msg_var = msg;
5254         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5255         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5256         long msg_ref = (long)msg_var.inner;
5257         if (msg_var.is_owned) {
5258                 msg_ref |= 1;
5259         }
5260         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5261         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5262         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5263         return ret_conv;
5264 }
5265 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5266         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5267         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5268         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5269         LDKQueryChannelRange msg_var = msg;
5270         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5271         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5272         long msg_ref = (long)msg_var.inner;
5273         if (msg_var.is_owned) {
5274                 msg_ref |= 1;
5275         }
5276         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
5277         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5278         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5279         return ret_conv;
5280 }
5281 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
5282         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5283         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5284         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5285         LDKQueryShortChannelIds msg_var = msg;
5286         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5287         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5288         long msg_ref = (long)msg_var.inner;
5289         if (msg_var.is_owned) {
5290                 msg_ref |= 1;
5291         }
5292         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
5293         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5294         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
5295         return ret_conv;
5296 }
5297 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
5298         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5299         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5300         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5301         return (void*) this_arg;
5302 }
5303 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5304         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
5305         atomic_init(&calls->refcnt, 1);
5306         //TODO: Assign calls->o from o
5307
5308         LDKRoutingMessageHandler ret = {
5309                 .this_arg = (void*) calls,
5310                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
5311                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
5312                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
5313                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
5314                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
5315                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
5316                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
5317                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
5318                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
5319                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
5320                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
5321                 .free = LDKRoutingMessageHandler_JCalls_free,
5322                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5323         };
5324         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5325         return ret;
5326 }
5327 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5328         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
5329         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
5330         return (long)res_ptr;
5331 }
5332 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
5333         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5334         LDKNodeAnnouncement msg_conv;
5335         msg_conv.inner = (void*)(msg & (~1));
5336         msg_conv.is_owned = false;
5337         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5338         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
5339         return (long)ret_conv;
5340 }
5341
5342 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
5343         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5344         LDKChannelAnnouncement msg_conv;
5345         msg_conv.inner = (void*)(msg & (~1));
5346         msg_conv.is_owned = false;
5347         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5348         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5349         return (long)ret_conv;
5350 }
5351
5352 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
5353         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5354         LDKChannelUpdate msg_conv;
5355         msg_conv.inner = (void*)(msg & (~1));
5356         msg_conv.is_owned = false;
5357         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5358         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
5359         return (long)ret_conv;
5360 }
5361
5362 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
5363         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5364         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
5365         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
5366 }
5367
5368 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
5369         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5370         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
5371         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5372         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5373         for (size_t l = 0; l < ret_var.datalen; l++) {
5374                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5375                 *ret_conv_63_ref = ret_var.data[l];
5376                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
5377         }
5378         FREE(ret_var.data);
5379         return ret_arr;
5380 }
5381
5382 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
5383         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5384         LDKPublicKey starting_point_ref;
5385         CHECK(*((uint32_t*)starting_point) == 33);
5386         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
5387         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
5388         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5389         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5390         for (size_t s = 0; s < ret_var.datalen; s++) {
5391                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
5392                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
5395                 if (ret_conv_18_var.is_owned) {
5396                         ret_conv_18_ref |= 1;
5397                 }
5398                 ret_arr_ptr[s] = ret_conv_18_ref;
5399         }
5400         FREE(ret_var.data);
5401         return ret_arr;
5402 }
5403
5404 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
5405         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5406         LDKPublicKey their_node_id_ref;
5407         CHECK(*((uint32_t*)their_node_id) == 33);
5408         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5409         LDKInit init_conv;
5410         init_conv.inner = (void*)(init & (~1));
5411         init_conv.is_owned = false;
5412         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
5413 }
5414
5415 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5416         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5417         LDKPublicKey their_node_id_ref;
5418         CHECK(*((uint32_t*)their_node_id) == 33);
5419         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5420         LDKReplyChannelRange msg_conv;
5421         msg_conv.inner = (void*)(msg & (~1));
5422         msg_conv.is_owned = (msg & 1) || (msg == 0);
5423         msg_conv = ReplyChannelRange_clone(&msg_conv);
5424         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5425         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5426         return (long)ret_conv;
5427 }
5428
5429 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) {
5430         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5431         LDKPublicKey their_node_id_ref;
5432         CHECK(*((uint32_t*)their_node_id) == 33);
5433         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5434         LDKReplyShortChannelIdsEnd msg_conv;
5435         msg_conv.inner = (void*)(msg & (~1));
5436         msg_conv.is_owned = (msg & 1) || (msg == 0);
5437         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
5438         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5439         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5440         return (long)ret_conv;
5441 }
5442
5443 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5444         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5445         LDKPublicKey their_node_id_ref;
5446         CHECK(*((uint32_t*)their_node_id) == 33);
5447         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5448         LDKQueryChannelRange msg_conv;
5449         msg_conv.inner = (void*)(msg & (~1));
5450         msg_conv.is_owned = (msg & 1) || (msg == 0);
5451         msg_conv = QueryChannelRange_clone(&msg_conv);
5452         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5453         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5454         return (long)ret_conv;
5455 }
5456
5457 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5458         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5459         LDKPublicKey their_node_id_ref;
5460         CHECK(*((uint32_t*)their_node_id) == 33);
5461         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5462         LDKQueryShortChannelIds msg_conv;
5463         msg_conv.inner = (void*)(msg & (~1));
5464         msg_conv.is_owned = (msg & 1) || (msg == 0);
5465         msg_conv = QueryShortChannelIds_clone(&msg_conv);
5466         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5467         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5468         return (long)ret_conv;
5469 }
5470
5471 typedef struct LDKSocketDescriptor_JCalls {
5472         atomic_size_t refcnt;
5473         uint32_t send_data_meth;
5474         uint32_t disconnect_socket_meth;
5475         uint32_t eq_meth;
5476         uint32_t hash_meth;
5477 } LDKSocketDescriptor_JCalls;
5478 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
5479         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5480         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5481                 js_free(j_calls->send_data_meth);
5482                 js_free(j_calls->disconnect_socket_meth);
5483                 js_free(j_calls->eq_meth);
5484                 js_free(j_calls->hash_meth);
5485                 FREE(j_calls);
5486         }
5487 }
5488 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
5489         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5490         LDKu8slice data_var = data;
5491         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5492         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
5493         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
5494 }
5495 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
5496         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5497         js_invoke_function_0(j_calls->disconnect_socket_meth);
5498 }
5499 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
5500         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5501         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5502         *other_arg_clone = SocketDescriptor_clone(other_arg);
5503         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
5504 }
5505 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
5506         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5507         return js_invoke_function_0(j_calls->hash_meth);
5508 }
5509 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
5510         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5511         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5512         return (void*) this_arg;
5513 }
5514 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
5515         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
5516         atomic_init(&calls->refcnt, 1);
5517         //TODO: Assign calls->o from o
5518
5519         LDKSocketDescriptor ret = {
5520                 .this_arg = (void*) calls,
5521                 .send_data = send_data_LDKSocketDescriptor_jcall,
5522                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
5523                 .eq = eq_LDKSocketDescriptor_jcall,
5524                 .hash = hash_LDKSocketDescriptor_jcall,
5525                 .clone = LDKSocketDescriptor_JCalls_clone,
5526                 .free = LDKSocketDescriptor_JCalls_free,
5527         };
5528         return ret;
5529 }
5530 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
5531         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5532         *res_ptr = LDKSocketDescriptor_init(o);
5533         return (long)res_ptr;
5534 }
5535 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
5536         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5537         LDKu8slice data_ref;
5538         data_ref.datalen = *((uint32_t*)data);
5539         data_ref.data = (int8_t*)(data + 4);
5540         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
5541         return ret_val;
5542 }
5543
5544 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
5545         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5546         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
5547 }
5548
5549 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
5550         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5551         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
5552         return ret_val;
5553 }
5554
5555 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
5556         LDKTransaction _res_ref;
5557         _res_ref.datalen = *((uint32_t*)_res);
5558         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
5559         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5560         _res_ref.data_is_owned = true;
5561         Transaction_free(_res_ref);
5562 }
5563
5564 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
5565         if ((_res & 1) != 0) return;
5566         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
5567         FREE((void*)_res);
5568         TxOut_free(_res_conv);
5569 }
5570
5571 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
5572         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
5573         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5574         *ret_ref = TxOut_clone(orig_conv);
5575         return (long)ret_ref;
5576 }
5577
5578 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
5579         LDKChannelConfig o_conv;
5580         o_conv.inner = (void*)(o & (~1));
5581         o_conv.is_owned = (o & 1) || (o == 0);
5582         o_conv = ChannelConfig_clone(&o_conv);
5583         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
5584         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
5585         return (long)ret_conv;
5586 }
5587
5588 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
5589         LDKDecodeError e_conv;
5590         e_conv.inner = (void*)(e & (~1));
5591         e_conv.is_owned = (e & 1) || (e == 0);
5592         e_conv = DecodeError_clone(&e_conv);
5593         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
5594         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
5595         return (long)ret_conv;
5596 }
5597
5598 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
5599         if ((_res & 1) != 0) return;
5600         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
5601         FREE((void*)_res);
5602         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
5603 }
5604
5605 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
5606         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
5607         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
5608         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
5609         return (long)ret_conv;
5610 }
5611
5612 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
5613         LDKOutPoint o_conv;
5614         o_conv.inner = (void*)(o & (~1));
5615         o_conv.is_owned = (o & 1) || (o == 0);
5616         o_conv = OutPoint_clone(&o_conv);
5617         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
5618         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
5619         return (long)ret_conv;
5620 }
5621
5622 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
5623         LDKDecodeError e_conv;
5624         e_conv.inner = (void*)(e & (~1));
5625         e_conv.is_owned = (e & 1) || (e == 0);
5626         e_conv = DecodeError_clone(&e_conv);
5627         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
5628         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
5629         return (long)ret_conv;
5630 }
5631
5632 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
5633         if ((_res & 1) != 0) return;
5634         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
5635         FREE((void*)_res);
5636         CResult_OutPointDecodeErrorZ_free(_res_conv);
5637 }
5638
5639 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
5640         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
5641         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
5642         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
5643         return (long)ret_conv;
5644 }
5645
5646 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
5647         LDKSecretKey o_ref;
5648         CHECK(*((uint32_t*)o) == 32);
5649         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5650         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5651         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
5652         return (long)ret_conv;
5653 }
5654
5655 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
5656         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5657         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5658         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
5659         return (long)ret_conv;
5660 }
5661
5662 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
5663         if ((_res & 1) != 0) return;
5664         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
5665         FREE((void*)_res);
5666         CResult_SecretKeyErrorZ_free(_res_conv);
5667 }
5668
5669 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
5670         LDKPublicKey o_ref;
5671         CHECK(*((uint32_t*)o) == 33);
5672         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5673         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5674         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
5675         return (long)ret_conv;
5676 }
5677
5678 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
5679         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5680         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5681         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
5682         return (long)ret_conv;
5683 }
5684
5685 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
5686         if ((_res & 1) != 0) return;
5687         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
5688         FREE((void*)_res);
5689         CResult_PublicKeyErrorZ_free(_res_conv);
5690 }
5691
5692 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
5693         LDKTxCreationKeys o_conv;
5694         o_conv.inner = (void*)(o & (~1));
5695         o_conv.is_owned = (o & 1) || (o == 0);
5696         o_conv = TxCreationKeys_clone(&o_conv);
5697         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5698         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
5699         return (long)ret_conv;
5700 }
5701
5702 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
5703         LDKDecodeError e_conv;
5704         e_conv.inner = (void*)(e & (~1));
5705         e_conv.is_owned = (e & 1) || (e == 0);
5706         e_conv = DecodeError_clone(&e_conv);
5707         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5708         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
5709         return (long)ret_conv;
5710 }
5711
5712 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
5713         if ((_res & 1) != 0) return;
5714         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5715         FREE((void*)_res);
5716         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
5717 }
5718
5719 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
5720         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
5721         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5722         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
5723         return (long)ret_conv;
5724 }
5725
5726 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
5727         LDKChannelPublicKeys o_conv;
5728         o_conv.inner = (void*)(o & (~1));
5729         o_conv.is_owned = (o & 1) || (o == 0);
5730         o_conv = ChannelPublicKeys_clone(&o_conv);
5731         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5732         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
5733         return (long)ret_conv;
5734 }
5735
5736 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
5737         LDKDecodeError e_conv;
5738         e_conv.inner = (void*)(e & (~1));
5739         e_conv.is_owned = (e & 1) || (e == 0);
5740         e_conv = DecodeError_clone(&e_conv);
5741         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5742         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
5743         return (long)ret_conv;
5744 }
5745
5746 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
5747         if ((_res & 1) != 0) return;
5748         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5749         FREE((void*)_res);
5750         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
5751 }
5752
5753 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
5754         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
5755         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5756         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
5757         return (long)ret_conv;
5758 }
5759
5760 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
5761         LDKTxCreationKeys o_conv;
5762         o_conv.inner = (void*)(o & (~1));
5763         o_conv.is_owned = (o & 1) || (o == 0);
5764         o_conv = TxCreationKeys_clone(&o_conv);
5765         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5766         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
5767         return (long)ret_conv;
5768 }
5769
5770 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
5771         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5772         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5773         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
5774         return (long)ret_conv;
5775 }
5776
5777 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
5778         if ((_res & 1) != 0) return;
5779         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
5780         FREE((void*)_res);
5781         CResult_TxCreationKeysErrorZ_free(_res_conv);
5782 }
5783
5784 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
5785         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5786         *ret_copy = COption_u32Z_some(o);
5787         long ret_ref = (long)ret_copy;
5788         return ret_ref;
5789 }
5790
5791 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
5792         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5793         *ret_copy = COption_u32Z_none();
5794         long ret_ref = (long)ret_copy;
5795         return ret_ref;
5796 }
5797
5798 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
5799         if ((_res & 1) != 0) return;
5800         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
5801         FREE((void*)_res);
5802         COption_u32Z_free(_res_conv);
5803 }
5804
5805 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
5806         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
5807         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
5808         *ret_copy = COption_u32Z_clone(orig_conv);
5809         long ret_ref = (long)ret_copy;
5810         return ret_ref;
5811 }
5812
5813 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
5814         LDKHTLCOutputInCommitment o_conv;
5815         o_conv.inner = (void*)(o & (~1));
5816         o_conv.is_owned = (o & 1) || (o == 0);
5817         o_conv = HTLCOutputInCommitment_clone(&o_conv);
5818         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5819         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
5820         return (long)ret_conv;
5821 }
5822
5823 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
5824         LDKDecodeError e_conv;
5825         e_conv.inner = (void*)(e & (~1));
5826         e_conv.is_owned = (e & 1) || (e == 0);
5827         e_conv = DecodeError_clone(&e_conv);
5828         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5829         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
5830         return (long)ret_conv;
5831 }
5832
5833 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
5834         if ((_res & 1) != 0) return;
5835         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
5836         FREE((void*)_res);
5837         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
5838 }
5839
5840 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
5841         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
5842         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5843         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
5844         return (long)ret_conv;
5845 }
5846
5847 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5848         LDKCounterpartyChannelTransactionParameters o_conv;
5849         o_conv.inner = (void*)(o & (~1));
5850         o_conv.is_owned = (o & 1) || (o == 0);
5851         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
5852         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5853         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5854         return (long)ret_conv;
5855 }
5856
5857 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5858         LDKDecodeError e_conv;
5859         e_conv.inner = (void*)(e & (~1));
5860         e_conv.is_owned = (e & 1) || (e == 0);
5861         e_conv = DecodeError_clone(&e_conv);
5862         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5863         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
5864         return (long)ret_conv;
5865 }
5866
5867 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5868         if ((_res & 1) != 0) return;
5869         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5870         FREE((void*)_res);
5871         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5872 }
5873
5874 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5875         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5876         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5877         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5878         return (long)ret_conv;
5879 }
5880
5881 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5882         LDKChannelTransactionParameters o_conv;
5883         o_conv.inner = (void*)(o & (~1));
5884         o_conv.is_owned = (o & 1) || (o == 0);
5885         o_conv = ChannelTransactionParameters_clone(&o_conv);
5886         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5887         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5888         return (long)ret_conv;
5889 }
5890
5891 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5892         LDKDecodeError e_conv;
5893         e_conv.inner = (void*)(e & (~1));
5894         e_conv.is_owned = (e & 1) || (e == 0);
5895         e_conv = DecodeError_clone(&e_conv);
5896         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5897         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
5898         return (long)ret_conv;
5899 }
5900
5901 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5902         if ((_res & 1) != 0) return;
5903         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5904         FREE((void*)_res);
5905         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5906 }
5907
5908 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5909         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5910         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5911         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5912         return (long)ret_conv;
5913 }
5914
5915 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
5916         LDKCVec_SignatureZ _res_constr;
5917         _res_constr.datalen = *((uint32_t*)_res);
5918         if (_res_constr.datalen > 0)
5919                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5920         else
5921                 _res_constr.data = NULL;
5922         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5923         for (size_t m = 0; m < _res_constr.datalen; m++) {
5924                 int8_tArray _res_conv_12 = _res_vals[m];
5925                 LDKSignature _res_conv_12_ref;
5926                 CHECK(*((uint32_t*)_res_conv_12) == 64);
5927                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
5928                 _res_constr.data[m] = _res_conv_12_ref;
5929         }
5930         CVec_SignatureZ_free(_res_constr);
5931 }
5932
5933 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5934         LDKHolderCommitmentTransaction o_conv;
5935         o_conv.inner = (void*)(o & (~1));
5936         o_conv.is_owned = (o & 1) || (o == 0);
5937         o_conv = HolderCommitmentTransaction_clone(&o_conv);
5938         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5939         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
5940         return (long)ret_conv;
5941 }
5942
5943 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5944         LDKDecodeError e_conv;
5945         e_conv.inner = (void*)(e & (~1));
5946         e_conv.is_owned = (e & 1) || (e == 0);
5947         e_conv = DecodeError_clone(&e_conv);
5948         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5949         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
5950         return (long)ret_conv;
5951 }
5952
5953 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5954         if ((_res & 1) != 0) return;
5955         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5956         FREE((void*)_res);
5957         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
5958 }
5959
5960 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5961         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5962         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5963         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5964         return (long)ret_conv;
5965 }
5966
5967 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5968         LDKBuiltCommitmentTransaction o_conv;
5969         o_conv.inner = (void*)(o & (~1));
5970         o_conv.is_owned = (o & 1) || (o == 0);
5971         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
5972         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5973         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
5974         return (long)ret_conv;
5975 }
5976
5977 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5978         LDKDecodeError e_conv;
5979         e_conv.inner = (void*)(e & (~1));
5980         e_conv.is_owned = (e & 1) || (e == 0);
5981         e_conv = DecodeError_clone(&e_conv);
5982         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5983         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
5984         return (long)ret_conv;
5985 }
5986
5987 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5988         if ((_res & 1) != 0) return;
5989         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5990         FREE((void*)_res);
5991         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
5992 }
5993
5994 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5995         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5996         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5997         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5998         return (long)ret_conv;
5999 }
6000
6001 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6002         LDKCommitmentTransaction o_conv;
6003         o_conv.inner = (void*)(o & (~1));
6004         o_conv.is_owned = (o & 1) || (o == 0);
6005         o_conv = CommitmentTransaction_clone(&o_conv);
6006         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6007         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6008         return (long)ret_conv;
6009 }
6010
6011 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6012         LDKDecodeError e_conv;
6013         e_conv.inner = (void*)(e & (~1));
6014         e_conv.is_owned = (e & 1) || (e == 0);
6015         e_conv = DecodeError_clone(&e_conv);
6016         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6017         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6018         return (long)ret_conv;
6019 }
6020
6021 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6022         if ((_res & 1) != 0) return;
6023         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6024         FREE((void*)_res);
6025         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6026 }
6027
6028 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6029         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6030         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6031         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6032         return (long)ret_conv;
6033 }
6034
6035 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6036         LDKTrustedCommitmentTransaction o_conv;
6037         o_conv.inner = (void*)(o & (~1));
6038         o_conv.is_owned = (o & 1) || (o == 0);
6039         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6040         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6041         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6042         return (long)ret_conv;
6043 }
6044
6045 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6046         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6047         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6048         return (long)ret_conv;
6049 }
6050
6051 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6052         if ((_res & 1) != 0) return;
6053         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6054         FREE((void*)_res);
6055         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6056 }
6057
6058 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
6059         LDKCVec_SignatureZ o_constr;
6060         o_constr.datalen = *((uint32_t*)o);
6061         if (o_constr.datalen > 0)
6062                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6063         else
6064                 o_constr.data = NULL;
6065         int8_tArray* o_vals = (int8_tArray*)(o + 4);
6066         for (size_t m = 0; m < o_constr.datalen; m++) {
6067                 int8_tArray o_conv_12 = o_vals[m];
6068                 LDKSignature o_conv_12_ref;
6069                 CHECK(*((uint32_t*)o_conv_12) == 64);
6070                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
6071                 o_constr.data[m] = o_conv_12_ref;
6072         }
6073         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6074         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6075         return (long)ret_conv;
6076 }
6077
6078 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
6079         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6080         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6081         return (long)ret_conv;
6082 }
6083
6084 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
6085         if ((_res & 1) != 0) return;
6086         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6087         FREE((void*)_res);
6088         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6089 }
6090
6091 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
6092         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6093         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6094         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6095         return (long)ret_conv;
6096 }
6097
6098 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
6099         LDKChannelMonitorUpdate o_conv;
6100         o_conv.inner = (void*)(o & (~1));
6101         o_conv.is_owned = (o & 1) || (o == 0);
6102         o_conv = ChannelMonitorUpdate_clone(&o_conv);
6103         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6104         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
6105         return (long)ret_conv;
6106 }
6107
6108 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
6109         LDKDecodeError e_conv;
6110         e_conv.inner = (void*)(e & (~1));
6111         e_conv.is_owned = (e & 1) || (e == 0);
6112         e_conv = DecodeError_clone(&e_conv);
6113         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6114         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
6115         return (long)ret_conv;
6116 }
6117
6118 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
6119         if ((_res & 1) != 0) return;
6120         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6121         FREE((void*)_res);
6122         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
6123 }
6124
6125 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
6126         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
6127         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6128         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
6129         return (long)ret_conv;
6130 }
6131
6132 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
6133         LDKHTLCUpdate o_conv;
6134         o_conv.inner = (void*)(o & (~1));
6135         o_conv.is_owned = (o & 1) || (o == 0);
6136         o_conv = HTLCUpdate_clone(&o_conv);
6137         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6138         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
6139         return (long)ret_conv;
6140 }
6141
6142 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
6143         LDKDecodeError e_conv;
6144         e_conv.inner = (void*)(e & (~1));
6145         e_conv.is_owned = (e & 1) || (e == 0);
6146         e_conv = DecodeError_clone(&e_conv);
6147         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6148         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
6149         return (long)ret_conv;
6150 }
6151
6152 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
6153         if ((_res & 1) != 0) return;
6154         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6155         FREE((void*)_res);
6156         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
6157 }
6158
6159 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
6160         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
6161         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6162         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
6163         return (long)ret_conv;
6164 }
6165
6166 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
6167         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6168         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
6169         return (long)ret_conv;
6170 }
6171
6172 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
6173         LDKMonitorUpdateError e_conv;
6174         e_conv.inner = (void*)(e & (~1));
6175         e_conv.is_owned = (e & 1) || (e == 0);
6176         e_conv = MonitorUpdateError_clone(&e_conv);
6177         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6178         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
6179         return (long)ret_conv;
6180 }
6181
6182 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
6183         if ((_res & 1) != 0) return;
6184         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
6185         FREE((void*)_res);
6186         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
6187 }
6188
6189 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
6190         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
6191         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6192         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
6193         return (long)ret_conv;
6194 }
6195
6196 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
6197         LDKOutPoint a_conv;
6198         a_conv.inner = (void*)(a & (~1));
6199         a_conv.is_owned = (a & 1) || (a == 0);
6200         a_conv = OutPoint_clone(&a_conv);
6201         LDKCVec_u8Z b_ref;
6202         b_ref.datalen = *((uint32_t*)b);
6203         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6204         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6205         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6206         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
6207         return (long)ret_ref;
6208 }
6209
6210 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
6211         if ((_res & 1) != 0) return;
6212         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
6213         FREE((void*)_res);
6214         C2Tuple_OutPointScriptZ_free(_res_conv);
6215 }
6216
6217 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
6218         LDKCVec_u8Z b_ref;
6219         b_ref.datalen = *((uint32_t*)b);
6220         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6221         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6222         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6223         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
6224         return (long)ret_ref;
6225 }
6226
6227 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
6228         if ((_res & 1) != 0) return;
6229         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
6230         FREE((void*)_res);
6231         C2Tuple_u32ScriptZ_free(_res_conv);
6232 }
6233
6234 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
6235         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
6236         _res_constr.datalen = *((uint32_t*)_res);
6237         if (_res_constr.datalen > 0)
6238                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6239         else
6240                 _res_constr.data = NULL;
6241         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6242         for (size_t e = 0; e < _res_constr.datalen; e++) {
6243                 uint32_t _res_conv_30 = _res_vals[e];
6244                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
6245                 FREE((void*)_res_conv_30);
6246                 _res_constr.data[e] = _res_conv_30_conv;
6247         }
6248         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
6249 }
6250
6251 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
6252         LDKThirtyTwoBytes a_ref;
6253         CHECK(*((uint32_t*)a) == 32);
6254         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6255         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
6256         b_constr.datalen = *((uint32_t*)b);
6257         if (b_constr.datalen > 0)
6258                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6259         else
6260                 b_constr.data = NULL;
6261         uint32_t* b_vals = (uint32_t*)(b + 4);
6262         for (size_t e = 0; e < b_constr.datalen; e++) {
6263                 uint32_t b_conv_30 = b_vals[e];
6264                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
6265                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
6266                 b_constr.data[e] = b_conv_30_conv;
6267         }
6268         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
6269         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
6270         return (long)ret_ref;
6271 }
6272
6273 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
6274         if ((_res & 1) != 0) return;
6275         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
6276         FREE((void*)_res);
6277         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
6278 }
6279
6280 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
6281         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
6282         _res_constr.datalen = *((uint32_t*)_res);
6283         if (_res_constr.datalen > 0)
6284                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
6285         else
6286                 _res_constr.data = NULL;
6287         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6288         for (size_t c = 0; c < _res_constr.datalen; c++) {
6289                 uint32_t _res_conv_54 = _res_vals[c];
6290                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
6291                 FREE((void*)_res_conv_54);
6292                 _res_constr.data[c] = _res_conv_54_conv;
6293         }
6294         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
6295 }
6296
6297 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
6298         LDKCVec_MonitorEventZ _res_constr;
6299         _res_constr.datalen = *((uint32_t*)_res);
6300         if (_res_constr.datalen > 0)
6301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6302         else
6303                 _res_constr.data = NULL;
6304         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6305         for (size_t o = 0; o < _res_constr.datalen; o++) {
6306                 uint32_t _res_conv_14 = _res_vals[o];
6307                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
6308                 FREE((void*)_res_conv_14);
6309                 _res_constr.data[o] = _res_conv_14_conv;
6310         }
6311         CVec_MonitorEventZ_free(_res_constr);
6312 }
6313
6314 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
6315         LDKCVec_EventZ _res_constr;
6316         _res_constr.datalen = *((uint32_t*)_res);
6317         if (_res_constr.datalen > 0)
6318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
6319         else
6320                 _res_constr.data = NULL;
6321         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6322         for (size_t h = 0; h < _res_constr.datalen; h++) {
6323                 uint32_t _res_conv_7 = _res_vals[h];
6324                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
6325                 FREE((void*)_res_conv_7);
6326                 _res_constr.data[h] = _res_conv_7_conv;
6327         }
6328         CVec_EventZ_free(_res_constr);
6329 }
6330
6331 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
6332         LDKCVec_TransactionZ _res_constr;
6333         _res_constr.datalen = *((uint32_t*)_res);
6334         if (_res_constr.datalen > 0)
6335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6336         else
6337                 _res_constr.data = NULL;
6338         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6339         for (size_t m = 0; m < _res_constr.datalen; m++) {
6340                 int8_tArray _res_conv_12 = _res_vals[m];
6341                 LDKTransaction _res_conv_12_ref;
6342                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
6343                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
6344                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
6345                 _res_conv_12_ref.data_is_owned = true;
6346                 _res_constr.data[m] = _res_conv_12_ref;
6347         }
6348         CVec_TransactionZ_free(_res_constr);
6349 }
6350
6351 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
6352         LDKTransaction b_ref;
6353         b_ref.datalen = *((uint32_t*)b);
6354         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
6355         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6356         b_ref.data_is_owned = true;
6357         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6358         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
6359         return (long)ret_ref;
6360 }
6361
6362 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
6363         if ((_res & 1) != 0) return;
6364         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
6365         FREE((void*)_res);
6366         C2Tuple_usizeTransactionZ_free(_res_conv);
6367 }
6368
6369 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
6370         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
6371         _res_constr.datalen = *((uint32_t*)_res);
6372         if (_res_constr.datalen > 0)
6373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6374         else
6375                 _res_constr.data = NULL;
6376         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6377         for (size_t e = 0; e < _res_constr.datalen; e++) {
6378                 uint32_t _res_conv_30 = _res_vals[e];
6379                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
6380                 FREE((void*)_res_conv_30);
6381                 _res_constr.data[e] = _res_conv_30_conv;
6382         }
6383         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
6384 }
6385
6386 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
6387         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
6388         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6389         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
6390         return (long)ret_ref;
6391 }
6392
6393 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
6394         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
6395         FREE((void*)b);
6396         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6397         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
6398         return (long)ret_ref;
6399 }
6400
6401 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
6402         if ((_res & 1) != 0) return;
6403         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
6404         FREE((void*)_res);
6405         C2Tuple_u32TxOutZ_free(_res_conv);
6406 }
6407
6408 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
6409         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
6410         _res_constr.datalen = *((uint32_t*)_res);
6411         if (_res_constr.datalen > 0)
6412                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6413         else
6414                 _res_constr.data = NULL;
6415         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6416         for (size_t z = 0; z < _res_constr.datalen; z++) {
6417                 uint32_t _res_conv_25 = _res_vals[z];
6418                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
6419                 FREE((void*)_res_conv_25);
6420                 _res_constr.data[z] = _res_conv_25_conv;
6421         }
6422         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
6423 }
6424
6425 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
6426         LDKThirtyTwoBytes a_ref;
6427         CHECK(*((uint32_t*)a) == 32);
6428         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6429         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
6430         b_constr.datalen = *((uint32_t*)b);
6431         if (b_constr.datalen > 0)
6432                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6433         else
6434                 b_constr.data = NULL;
6435         uint32_t* b_vals = (uint32_t*)(b + 4);
6436         for (size_t z = 0; z < b_constr.datalen; z++) {
6437                 uint32_t b_conv_25 = b_vals[z];
6438                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
6439                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
6440                 b_constr.data[z] = b_conv_25_conv;
6441         }
6442         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
6443         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
6444         return (long)ret_ref;
6445 }
6446
6447 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
6448         if ((_res & 1) != 0) return;
6449         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
6450         FREE((void*)_res);
6451         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
6452 }
6453
6454 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
6455         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
6456         _res_constr.datalen = *((uint32_t*)_res);
6457         if (_res_constr.datalen > 0)
6458                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
6459         else
6460                 _res_constr.data = NULL;
6461         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6462         for (size_t x = 0; x < _res_constr.datalen; x++) {
6463                 uint32_t _res_conv_49 = _res_vals[x];
6464                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
6465                 FREE((void*)_res_conv_49);
6466                 _res_constr.data[x] = _res_conv_49_conv;
6467         }
6468         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
6469 }
6470
6471 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
6472         LDKCVec_TxidZ _res_constr;
6473         _res_constr.datalen = *((uint32_t*)_res);
6474         if (_res_constr.datalen > 0)
6475                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6476         else
6477                 _res_constr.data = NULL;
6478         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6479         for (size_t m = 0; m < _res_constr.datalen; m++) {
6480                 int8_tArray _res_conv_12 = _res_vals[m];
6481                 LDKThirtyTwoBytes _res_conv_12_ref;
6482                 CHECK(*((uint32_t*)_res_conv_12) == 32);
6483                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
6484                 _res_constr.data[m] = _res_conv_12_ref;
6485         }
6486         CVec_TxidZ_free(_res_constr);
6487 }
6488
6489 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
6490         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6491         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
6492         return (long)ret_conv;
6493 }
6494
6495 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
6496         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
6497         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6498         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
6499         return (long)ret_conv;
6500 }
6501
6502 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
6503         if ((_res & 1) != 0) return;
6504         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
6505         FREE((void*)_res);
6506         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
6507 }
6508
6509 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
6510         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
6511         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6512         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
6513         return (long)ret_conv;
6514 }
6515
6516 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
6517         LDKThirtyTwoBytes a_ref;
6518         CHECK(*((uint32_t*)a) == 32);
6519         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6520         LDKChannelMonitor b_conv;
6521         b_conv.inner = (void*)(b & (~1));
6522         b_conv.is_owned = (b & 1) || (b == 0);
6523         b_conv = ChannelMonitor_clone(&b_conv);
6524         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6525         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
6526         return (long)ret_ref;
6527 }
6528
6529 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
6530         if ((_res & 1) != 0) return;
6531         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
6532         FREE((void*)_res);
6533         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
6534 }
6535
6536 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
6537         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
6538         FREE((void*)o);
6539         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6540         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
6541         return (long)ret_conv;
6542 }
6543
6544 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
6545         LDKDecodeError e_conv;
6546         e_conv.inner = (void*)(e & (~1));
6547         e_conv.is_owned = (e & 1) || (e == 0);
6548         e_conv = DecodeError_clone(&e_conv);
6549         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6550         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
6551         return (long)ret_conv;
6552 }
6553
6554 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
6555         if ((_res & 1) != 0) return;
6556         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
6557         FREE((void*)_res);
6558         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
6559 }
6560
6561 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6562         LDKCVec_RouteHopZ _res_constr;
6563         _res_constr.datalen = *((uint32_t*)_res);
6564         if (_res_constr.datalen > 0)
6565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6566         else
6567                 _res_constr.data = NULL;
6568         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6569         for (size_t k = 0; k < _res_constr.datalen; k++) {
6570                 uint32_t _res_conv_10 = _res_vals[k];
6571                 LDKRouteHop _res_conv_10_conv;
6572                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
6573                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
6574                 _res_constr.data[k] = _res_conv_10_conv;
6575         }
6576         CVec_RouteHopZ_free(_res_constr);
6577 }
6578
6579 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
6580         LDKCVec_CVec_RouteHopZZ _res_constr;
6581         _res_constr.datalen = *((uint32_t*)_res);
6582         if (_res_constr.datalen > 0)
6583                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
6584         else
6585                 _res_constr.data = NULL;
6586         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
6587         for (size_t m = 0; m < _res_constr.datalen; m++) {
6588                 uint32_tArray _res_conv_12 = _res_vals[m];
6589                 LDKCVec_RouteHopZ _res_conv_12_constr;
6590                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
6591                 if (_res_conv_12_constr.datalen > 0)
6592                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6593                 else
6594                         _res_conv_12_constr.data = NULL;
6595                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
6596                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
6597                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
6598                         LDKRouteHop _res_conv_12_conv_10_conv;
6599                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
6600                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
6601                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
6602                 }
6603                 _res_constr.data[m] = _res_conv_12_constr;
6604         }
6605         CVec_CVec_RouteHopZZ_free(_res_constr);
6606 }
6607
6608 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
6609         LDKRoute o_conv;
6610         o_conv.inner = (void*)(o & (~1));
6611         o_conv.is_owned = (o & 1) || (o == 0);
6612         o_conv = Route_clone(&o_conv);
6613         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6614         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
6615         return (long)ret_conv;
6616 }
6617
6618 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
6619         LDKDecodeError e_conv;
6620         e_conv.inner = (void*)(e & (~1));
6621         e_conv.is_owned = (e & 1) || (e == 0);
6622         e_conv = DecodeError_clone(&e_conv);
6623         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6624         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
6625         return (long)ret_conv;
6626 }
6627
6628 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
6629         if ((_res & 1) != 0) return;
6630         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
6631         FREE((void*)_res);
6632         CResult_RouteDecodeErrorZ_free(_res_conv);
6633 }
6634
6635 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
6636         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
6637         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6638         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
6639         return (long)ret_conv;
6640 }
6641
6642 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
6643         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6644         *ret_copy = COption_u64Z_some(o);
6645         long ret_ref = (long)ret_copy;
6646         return ret_ref;
6647 }
6648
6649 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
6650         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6651         *ret_copy = COption_u64Z_none();
6652         long ret_ref = (long)ret_copy;
6653         return ret_ref;
6654 }
6655
6656 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
6657         if ((_res & 1) != 0) return;
6658         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
6659         FREE((void*)_res);
6660         COption_u64Z_free(_res_conv);
6661 }
6662
6663 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
6664         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
6665         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
6666         *ret_copy = COption_u64Z_clone(orig_conv);
6667         long ret_ref = (long)ret_copy;
6668         return ret_ref;
6669 }
6670
6671 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
6672         LDKCVec_ChannelDetailsZ _res_constr;
6673         _res_constr.datalen = *((uint32_t*)_res);
6674         if (_res_constr.datalen > 0)
6675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6676         else
6677                 _res_constr.data = NULL;
6678         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6679         for (size_t q = 0; q < _res_constr.datalen; q++) {
6680                 uint32_t _res_conv_16 = _res_vals[q];
6681                 LDKChannelDetails _res_conv_16_conv;
6682                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
6683                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
6684                 _res_constr.data[q] = _res_conv_16_conv;
6685         }
6686         CVec_ChannelDetailsZ_free(_res_constr);
6687 }
6688
6689 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
6690         LDKCVec_RouteHintZ _res_constr;
6691         _res_constr.datalen = *((uint32_t*)_res);
6692         if (_res_constr.datalen > 0)
6693                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
6694         else
6695                 _res_constr.data = NULL;
6696         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6697         for (size_t l = 0; l < _res_constr.datalen; l++) {
6698                 uint32_t _res_conv_11 = _res_vals[l];
6699                 LDKRouteHint _res_conv_11_conv;
6700                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
6701                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
6702                 _res_constr.data[l] = _res_conv_11_conv;
6703         }
6704         CVec_RouteHintZ_free(_res_constr);
6705 }
6706
6707 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
6708         LDKRoute o_conv;
6709         o_conv.inner = (void*)(o & (~1));
6710         o_conv.is_owned = (o & 1) || (o == 0);
6711         o_conv = Route_clone(&o_conv);
6712         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6713         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
6714         return (long)ret_conv;
6715 }
6716
6717 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
6718         LDKLightningError e_conv;
6719         e_conv.inner = (void*)(e & (~1));
6720         e_conv.is_owned = (e & 1) || (e == 0);
6721         e_conv = LightningError_clone(&e_conv);
6722         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6723         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
6724         return (long)ret_conv;
6725 }
6726
6727 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
6728         if ((_res & 1) != 0) return;
6729         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
6730         FREE((void*)_res);
6731         CResult_RouteLightningErrorZ_free(_res_conv);
6732 }
6733
6734 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
6735         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
6736         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6737         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
6738         return (long)ret_conv;
6739 }
6740
6741 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
6742         LDKCVec_MessageSendEventZ _res_constr;
6743         _res_constr.datalen = *((uint32_t*)_res);
6744         if (_res_constr.datalen > 0)
6745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6746         else
6747                 _res_constr.data = NULL;
6748         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6749         for (size_t s = 0; s < _res_constr.datalen; s++) {
6750                 uint32_t _res_conv_18 = _res_vals[s];
6751                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
6752                 FREE((void*)_res_conv_18);
6753                 _res_constr.data[s] = _res_conv_18_conv;
6754         }
6755         CVec_MessageSendEventZ_free(_res_constr);
6756 }
6757
6758 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
6759         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6760         *ret_conv = CResult_boolLightningErrorZ_ok(o);
6761         return (long)ret_conv;
6762 }
6763
6764 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
6765         LDKLightningError e_conv;
6766         e_conv.inner = (void*)(e & (~1));
6767         e_conv.is_owned = (e & 1) || (e == 0);
6768         e_conv = LightningError_clone(&e_conv);
6769         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6770         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
6771         return (long)ret_conv;
6772 }
6773
6774 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
6775         if ((_res & 1) != 0) return;
6776         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
6777         FREE((void*)_res);
6778         CResult_boolLightningErrorZ_free(_res_conv);
6779 }
6780
6781 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
6782         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
6783         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6784         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
6785         return (long)ret_conv;
6786 }
6787
6788 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
6789         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
6790         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6791         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
6792         return (long)ret_ref;
6793 }
6794
6795 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
6796         LDKChannelAnnouncement a_conv;
6797         a_conv.inner = (void*)(a & (~1));
6798         a_conv.is_owned = (a & 1) || (a == 0);
6799         a_conv = ChannelAnnouncement_clone(&a_conv);
6800         LDKChannelUpdate b_conv;
6801         b_conv.inner = (void*)(b & (~1));
6802         b_conv.is_owned = (b & 1) || (b == 0);
6803         b_conv = ChannelUpdate_clone(&b_conv);
6804         LDKChannelUpdate c_conv;
6805         c_conv.inner = (void*)(c & (~1));
6806         c_conv.is_owned = (c & 1) || (c == 0);
6807         c_conv = ChannelUpdate_clone(&c_conv);
6808         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6809         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
6810         return (long)ret_ref;
6811 }
6812
6813 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
6814         if ((_res & 1) != 0) return;
6815         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
6816         FREE((void*)_res);
6817         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
6818 }
6819
6820 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
6821         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
6822         _res_constr.datalen = *((uint32_t*)_res);
6823         if (_res_constr.datalen > 0)
6824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6825         else
6826                 _res_constr.data = NULL;
6827         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6828         for (size_t l = 0; l < _res_constr.datalen; l++) {
6829                 uint32_t _res_conv_63 = _res_vals[l];
6830                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
6831                 FREE((void*)_res_conv_63);
6832                 _res_constr.data[l] = _res_conv_63_conv;
6833         }
6834         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
6835 }
6836
6837 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
6838         LDKCVec_NodeAnnouncementZ _res_constr;
6839         _res_constr.datalen = *((uint32_t*)_res);
6840         if (_res_constr.datalen > 0)
6841                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6842         else
6843                 _res_constr.data = NULL;
6844         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6845         for (size_t s = 0; s < _res_constr.datalen; s++) {
6846                 uint32_t _res_conv_18 = _res_vals[s];
6847                 LDKNodeAnnouncement _res_conv_18_conv;
6848                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
6849                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
6850                 _res_constr.data[s] = _res_conv_18_conv;
6851         }
6852         CVec_NodeAnnouncementZ_free(_res_constr);
6853 }
6854
6855 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
6856         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6857         *ret_conv = CResult_NoneLightningErrorZ_ok();
6858         return (long)ret_conv;
6859 }
6860
6861 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
6862         LDKLightningError e_conv;
6863         e_conv.inner = (void*)(e & (~1));
6864         e_conv.is_owned = (e & 1) || (e == 0);
6865         e_conv = LightningError_clone(&e_conv);
6866         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6867         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
6868         return (long)ret_conv;
6869 }
6870
6871 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
6872         if ((_res & 1) != 0) return;
6873         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
6874         FREE((void*)_res);
6875         CResult_NoneLightningErrorZ_free(_res_conv);
6876 }
6877
6878 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
6879         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
6880         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6881         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
6882         return (long)ret_conv;
6883 }
6884
6885 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
6886         LDKCVec_PublicKeyZ _res_constr;
6887         _res_constr.datalen = *((uint32_t*)_res);
6888         if (_res_constr.datalen > 0)
6889                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
6890         else
6891                 _res_constr.data = NULL;
6892         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6893         for (size_t m = 0; m < _res_constr.datalen; m++) {
6894                 int8_tArray _res_conv_12 = _res_vals[m];
6895                 LDKPublicKey _res_conv_12_ref;
6896                 CHECK(*((uint32_t*)_res_conv_12) == 33);
6897                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
6898                 _res_constr.data[m] = _res_conv_12_ref;
6899         }
6900         CVec_PublicKeyZ_free(_res_constr);
6901 }
6902
6903 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
6904         LDKCVec_u8Z _res_ref;
6905         _res_ref.datalen = *((uint32_t*)_res);
6906         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
6907         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6908         CVec_u8Z_free(_res_ref);
6909 }
6910
6911 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
6912         LDKCVec_u8Z o_ref;
6913         o_ref.datalen = *((uint32_t*)o);
6914         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
6915         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
6916         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6917         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
6918         return (long)ret_conv;
6919 }
6920
6921 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
6922         LDKPeerHandleError e_conv;
6923         e_conv.inner = (void*)(e & (~1));
6924         e_conv.is_owned = (e & 1) || (e == 0);
6925         e_conv = PeerHandleError_clone(&e_conv);
6926         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6927         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
6928         return (long)ret_conv;
6929 }
6930
6931 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
6932         if ((_res & 1) != 0) return;
6933         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6934         FREE((void*)_res);
6935         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
6936 }
6937
6938 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
6939         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
6940         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
6941         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
6942         return (long)ret_conv;
6943 }
6944
6945 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
6946         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6947         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
6948         return (long)ret_conv;
6949 }
6950
6951 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
6952         LDKPeerHandleError e_conv;
6953         e_conv.inner = (void*)(e & (~1));
6954         e_conv.is_owned = (e & 1) || (e == 0);
6955         e_conv = PeerHandleError_clone(&e_conv);
6956         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6957         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
6958         return (long)ret_conv;
6959 }
6960
6961 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
6962         if ((_res & 1) != 0) return;
6963         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6964         FREE((void*)_res);
6965         CResult_NonePeerHandleErrorZ_free(_res_conv);
6966 }
6967
6968 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
6969         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
6970         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
6971         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
6972         return (long)ret_conv;
6973 }
6974
6975 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
6976         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6977         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
6978         return (long)ret_conv;
6979 }
6980
6981 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
6982         LDKPeerHandleError e_conv;
6983         e_conv.inner = (void*)(e & (~1));
6984         e_conv.is_owned = (e & 1) || (e == 0);
6985         e_conv = PeerHandleError_clone(&e_conv);
6986         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6987         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
6988         return (long)ret_conv;
6989 }
6990
6991 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
6992         if ((_res & 1) != 0) return;
6993         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6994         FREE((void*)_res);
6995         CResult_boolPeerHandleErrorZ_free(_res_conv);
6996 }
6997
6998 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
6999         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
7000         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
7001         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
7002         return (long)ret_conv;
7003 }
7004
7005 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7006         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7007         FREE((void*)o);
7008         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7009         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7010         return (long)ret_conv;
7011 }
7012
7013 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7014         LDKAccessError e_conv = LDKAccessError_from_js(e);
7015         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7016         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7017         return (long)ret_conv;
7018 }
7019
7020 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7021         if ((_res & 1) != 0) return;
7022         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7023         FREE((void*)_res);
7024         CResult_TxOutAccessErrorZ_free(_res_conv);
7025 }
7026
7027 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7028         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7029         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7030         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7031         return (long)ret_conv;
7032 }
7033
7034 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7035         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7036         FREE((void*)o);
7037         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7038         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7039         long ret_ref = (long)ret_copy;
7040         return ret_ref;
7041 }
7042
7043 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7044         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7045         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7046         long ret_ref = (long)ret_copy;
7047         return ret_ref;
7048 }
7049
7050 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7051         if ((_res & 1) != 0) return;
7052         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7053         FREE((void*)_res);
7054         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7055 }
7056
7057 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7058         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7059         _res_constr.datalen = *((uint32_t*)_res);
7060         if (_res_constr.datalen > 0)
7061                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7062         else
7063                 _res_constr.data = NULL;
7064         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7065         for (size_t b = 0; b < _res_constr.datalen; b++) {
7066                 uint32_t _res_conv_27 = _res_vals[b];
7067                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7068                 FREE((void*)_res_conv_27);
7069                 _res_constr.data[b] = _res_conv_27_conv;
7070         }
7071         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7072 }
7073
7074 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
7075         LDKDirectionalChannelInfo o_conv;
7076         o_conv.inner = (void*)(o & (~1));
7077         o_conv.is_owned = (o & 1) || (o == 0);
7078         o_conv = DirectionalChannelInfo_clone(&o_conv);
7079         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7080         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
7081         return (long)ret_conv;
7082 }
7083
7084 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
7085         LDKDecodeError e_conv;
7086         e_conv.inner = (void*)(e & (~1));
7087         e_conv.is_owned = (e & 1) || (e == 0);
7088         e_conv = DecodeError_clone(&e_conv);
7089         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7090         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
7091         return (long)ret_conv;
7092 }
7093
7094 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
7095         if ((_res & 1) != 0) return;
7096         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7097         FREE((void*)_res);
7098         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
7099 }
7100
7101 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
7102         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
7103         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
7104         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
7105         return (long)ret_conv;
7106 }
7107
7108 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
7109         LDKChannelInfo o_conv;
7110         o_conv.inner = (void*)(o & (~1));
7111         o_conv.is_owned = (o & 1) || (o == 0);
7112         o_conv = ChannelInfo_clone(&o_conv);
7113         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7114         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
7115         return (long)ret_conv;
7116 }
7117
7118 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
7119         LDKDecodeError e_conv;
7120         e_conv.inner = (void*)(e & (~1));
7121         e_conv.is_owned = (e & 1) || (e == 0);
7122         e_conv = DecodeError_clone(&e_conv);
7123         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7124         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
7125         return (long)ret_conv;
7126 }
7127
7128 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
7129         if ((_res & 1) != 0) return;
7130         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7131         FREE((void*)_res);
7132         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
7133 }
7134
7135 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
7136         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
7137         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
7138         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
7139         return (long)ret_conv;
7140 }
7141
7142 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
7143         LDKRoutingFees o_conv;
7144         o_conv.inner = (void*)(o & (~1));
7145         o_conv.is_owned = (o & 1) || (o == 0);
7146         o_conv = RoutingFees_clone(&o_conv);
7147         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7148         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
7149         return (long)ret_conv;
7150 }
7151
7152 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
7153         LDKDecodeError e_conv;
7154         e_conv.inner = (void*)(e & (~1));
7155         e_conv.is_owned = (e & 1) || (e == 0);
7156         e_conv = DecodeError_clone(&e_conv);
7157         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7158         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
7159         return (long)ret_conv;
7160 }
7161
7162 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
7163         if ((_res & 1) != 0) return;
7164         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7165         FREE((void*)_res);
7166         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
7167 }
7168
7169 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
7170         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
7171         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
7172         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
7173         return (long)ret_conv;
7174 }
7175
7176 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
7177         LDKCVec_NetAddressZ _res_constr;
7178         _res_constr.datalen = *((uint32_t*)_res);
7179         if (_res_constr.datalen > 0)
7180                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
7181         else
7182                 _res_constr.data = NULL;
7183         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7184         for (size_t m = 0; m < _res_constr.datalen; m++) {
7185                 uint32_t _res_conv_12 = _res_vals[m];
7186                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
7187                 FREE((void*)_res_conv_12);
7188                 _res_constr.data[m] = _res_conv_12_conv;
7189         }
7190         CVec_NetAddressZ_free(_res_constr);
7191 }
7192
7193 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
7194         LDKNodeAnnouncementInfo o_conv;
7195         o_conv.inner = (void*)(o & (~1));
7196         o_conv.is_owned = (o & 1) || (o == 0);
7197         o_conv = NodeAnnouncementInfo_clone(&o_conv);
7198         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7199         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
7200         return (long)ret_conv;
7201 }
7202
7203 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
7204         LDKDecodeError e_conv;
7205         e_conv.inner = (void*)(e & (~1));
7206         e_conv.is_owned = (e & 1) || (e == 0);
7207         e_conv = DecodeError_clone(&e_conv);
7208         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7209         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
7210         return (long)ret_conv;
7211 }
7212
7213 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
7214         if ((_res & 1) != 0) return;
7215         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7216         FREE((void*)_res);
7217         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
7218 }
7219
7220 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
7221         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
7222         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
7223         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
7224         return (long)ret_conv;
7225 }
7226
7227 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
7228         LDKCVec_u64Z _res_constr;
7229         _res_constr.datalen = *((uint32_t*)_res);
7230         if (_res_constr.datalen > 0)
7231                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
7232         else
7233                 _res_constr.data = NULL;
7234         int64_t* _res_vals = (int64_t*)(_res + 4);
7235         for (size_t i = 0; i < _res_constr.datalen; i++) {
7236                 int64_t _res_conv_8 = _res_vals[i];
7237                 _res_constr.data[i] = _res_conv_8;
7238         }
7239         CVec_u64Z_free(_res_constr);
7240 }
7241
7242 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
7243         LDKNodeInfo o_conv;
7244         o_conv.inner = (void*)(o & (~1));
7245         o_conv.is_owned = (o & 1) || (o == 0);
7246         o_conv = NodeInfo_clone(&o_conv);
7247         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7248         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
7249         return (long)ret_conv;
7250 }
7251
7252 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
7253         LDKDecodeError e_conv;
7254         e_conv.inner = (void*)(e & (~1));
7255         e_conv.is_owned = (e & 1) || (e == 0);
7256         e_conv = DecodeError_clone(&e_conv);
7257         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7258         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
7259         return (long)ret_conv;
7260 }
7261
7262 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
7263         if ((_res & 1) != 0) return;
7264         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
7265         FREE((void*)_res);
7266         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
7267 }
7268
7269 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
7270         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
7271         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
7272         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
7273         return (long)ret_conv;
7274 }
7275
7276 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
7277         LDKNetworkGraph o_conv;
7278         o_conv.inner = (void*)(o & (~1));
7279         o_conv.is_owned = (o & 1) || (o == 0);
7280         o_conv = NetworkGraph_clone(&o_conv);
7281         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7282         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
7283         return (long)ret_conv;
7284 }
7285
7286 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
7287         LDKDecodeError e_conv;
7288         e_conv.inner = (void*)(e & (~1));
7289         e_conv.is_owned = (e & 1) || (e == 0);
7290         e_conv = DecodeError_clone(&e_conv);
7291         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7292         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
7293         return (long)ret_conv;
7294 }
7295
7296 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
7297         if ((_res & 1) != 0) return;
7298         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
7299         FREE((void*)_res);
7300         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
7301 }
7302
7303 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
7304         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
7305         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
7306         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
7307         return (long)ret_conv;
7308 }
7309
7310 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7311         LDKInitFeatures o_conv;
7312         o_conv.inner = (void*)(o & (~1));
7313         o_conv.is_owned = (o & 1) || (o == 0);
7314         o_conv = InitFeatures_clone(&o_conv);
7315         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7316         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7317         return (long)ret_conv;
7318 }
7319
7320 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7321         LDKDecodeError e_conv;
7322         e_conv.inner = (void*)(e & (~1));
7323         e_conv.is_owned = (e & 1) || (e == 0);
7324         e_conv = DecodeError_clone(&e_conv);
7325         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7326         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7327         return (long)ret_conv;
7328 }
7329
7330 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7331         if ((_res & 1) != 0) return;
7332         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7333         FREE((void*)_res);
7334         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7335 }
7336
7337 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7338         LDKNodeFeatures o_conv;
7339         o_conv.inner = (void*)(o & (~1));
7340         o_conv.is_owned = (o & 1) || (o == 0);
7341         o_conv = NodeFeatures_clone(&o_conv);
7342         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7343         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7344         return (long)ret_conv;
7345 }
7346
7347 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7348         LDKDecodeError e_conv;
7349         e_conv.inner = (void*)(e & (~1));
7350         e_conv.is_owned = (e & 1) || (e == 0);
7351         e_conv = DecodeError_clone(&e_conv);
7352         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7353         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7354         return (long)ret_conv;
7355 }
7356
7357 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7358         if ((_res & 1) != 0) return;
7359         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7360         FREE((void*)_res);
7361         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7362 }
7363
7364 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7365         LDKChannelFeatures o_conv;
7366         o_conv.inner = (void*)(o & (~1));
7367         o_conv.is_owned = (o & 1) || (o == 0);
7368         o_conv = ChannelFeatures_clone(&o_conv);
7369         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7370         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7371         return (long)ret_conv;
7372 }
7373
7374 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7375         LDKDecodeError e_conv;
7376         e_conv.inner = (void*)(e & (~1));
7377         e_conv.is_owned = (e & 1) || (e == 0);
7378         e_conv = DecodeError_clone(&e_conv);
7379         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7380         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7381         return (long)ret_conv;
7382 }
7383
7384 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7385         if ((_res & 1) != 0) return;
7386         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7387         FREE((void*)_res);
7388         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7389 }
7390
7391 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7392         LDKInvoiceFeatures o_conv;
7393         o_conv.inner = (void*)(o & (~1));
7394         o_conv.is_owned = (o & 1) || (o == 0);
7395         o_conv = InvoiceFeatures_clone(&o_conv);
7396         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7397         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7398         return (long)ret_conv;
7399 }
7400
7401 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7402         LDKDecodeError e_conv;
7403         e_conv.inner = (void*)(e & (~1));
7404         e_conv.is_owned = (e & 1) || (e == 0);
7405         e_conv = DecodeError_clone(&e_conv);
7406         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7407         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7408         return (long)ret_conv;
7409 }
7410
7411 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7412         if ((_res & 1) != 0) return;
7413         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7414         FREE((void*)_res);
7415         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7416 }
7417
7418 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
7419         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
7420         FREE((void*)o);
7421         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7422         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
7423         return (long)ret_conv;
7424 }
7425
7426 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
7427         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7428         *ret_conv = CResult_NetAddressu8Z_err(e);
7429         return (long)ret_conv;
7430 }
7431
7432 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
7433         if ((_res & 1) != 0) return;
7434         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
7435         FREE((void*)_res);
7436         CResult_NetAddressu8Z_free(_res_conv);
7437 }
7438
7439 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
7440         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
7441         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7442         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
7443         return (long)ret_conv;
7444 }
7445
7446 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
7447         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
7448         FREE((void*)o);
7449         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7450         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
7451         return (long)ret_conv;
7452 }
7453
7454 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
7455         LDKDecodeError e_conv;
7456         e_conv.inner = (void*)(e & (~1));
7457         e_conv.is_owned = (e & 1) || (e == 0);
7458         e_conv = DecodeError_clone(&e_conv);
7459         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7460         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
7461         return (long)ret_conv;
7462 }
7463
7464 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
7465         if ((_res & 1) != 0) return;
7466         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7467         FREE((void*)_res);
7468         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
7469 }
7470
7471 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
7472         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
7473         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7474         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
7475         return (long)ret_conv;
7476 }
7477
7478 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
7479         LDKCVec_UpdateAddHTLCZ _res_constr;
7480         _res_constr.datalen = *((uint32_t*)_res);
7481         if (_res_constr.datalen > 0)
7482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
7483         else
7484                 _res_constr.data = NULL;
7485         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7486         for (size_t p = 0; p < _res_constr.datalen; p++) {
7487                 uint32_t _res_conv_15 = _res_vals[p];
7488                 LDKUpdateAddHTLC _res_conv_15_conv;
7489                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
7490                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
7491                 _res_constr.data[p] = _res_conv_15_conv;
7492         }
7493         CVec_UpdateAddHTLCZ_free(_res_constr);
7494 }
7495
7496 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
7497         LDKCVec_UpdateFulfillHTLCZ _res_constr;
7498         _res_constr.datalen = *((uint32_t*)_res);
7499         if (_res_constr.datalen > 0)
7500                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
7501         else
7502                 _res_constr.data = NULL;
7503         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7504         for (size_t t = 0; t < _res_constr.datalen; t++) {
7505                 uint32_t _res_conv_19 = _res_vals[t];
7506                 LDKUpdateFulfillHTLC _res_conv_19_conv;
7507                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
7508                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
7509                 _res_constr.data[t] = _res_conv_19_conv;
7510         }
7511         CVec_UpdateFulfillHTLCZ_free(_res_constr);
7512 }
7513
7514 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
7515         LDKCVec_UpdateFailHTLCZ _res_constr;
7516         _res_constr.datalen = *((uint32_t*)_res);
7517         if (_res_constr.datalen > 0)
7518                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
7519         else
7520                 _res_constr.data = NULL;
7521         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7522         for (size_t q = 0; q < _res_constr.datalen; q++) {
7523                 uint32_t _res_conv_16 = _res_vals[q];
7524                 LDKUpdateFailHTLC _res_conv_16_conv;
7525                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7526                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7527                 _res_constr.data[q] = _res_conv_16_conv;
7528         }
7529         CVec_UpdateFailHTLCZ_free(_res_constr);
7530 }
7531
7532 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
7533         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
7534         _res_constr.datalen = *((uint32_t*)_res);
7535         if (_res_constr.datalen > 0)
7536                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
7537         else
7538                 _res_constr.data = NULL;
7539         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7540         for (size_t z = 0; z < _res_constr.datalen; z++) {
7541                 uint32_t _res_conv_25 = _res_vals[z];
7542                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
7543                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
7544                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
7545                 _res_constr.data[z] = _res_conv_25_conv;
7546         }
7547         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
7548 }
7549
7550 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
7551         LDKAcceptChannel o_conv;
7552         o_conv.inner = (void*)(o & (~1));
7553         o_conv.is_owned = (o & 1) || (o == 0);
7554         o_conv = AcceptChannel_clone(&o_conv);
7555         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7556         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
7557         return (long)ret_conv;
7558 }
7559
7560 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
7561         LDKDecodeError e_conv;
7562         e_conv.inner = (void*)(e & (~1));
7563         e_conv.is_owned = (e & 1) || (e == 0);
7564         e_conv = DecodeError_clone(&e_conv);
7565         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7566         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
7567         return (long)ret_conv;
7568 }
7569
7570 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
7571         if ((_res & 1) != 0) return;
7572         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7573         FREE((void*)_res);
7574         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
7575 }
7576
7577 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
7578         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
7579         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7580         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
7581         return (long)ret_conv;
7582 }
7583
7584 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
7585         LDKAnnouncementSignatures o_conv;
7586         o_conv.inner = (void*)(o & (~1));
7587         o_conv.is_owned = (o & 1) || (o == 0);
7588         o_conv = AnnouncementSignatures_clone(&o_conv);
7589         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7590         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
7591         return (long)ret_conv;
7592 }
7593
7594 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
7595         LDKDecodeError e_conv;
7596         e_conv.inner = (void*)(e & (~1));
7597         e_conv.is_owned = (e & 1) || (e == 0);
7598         e_conv = DecodeError_clone(&e_conv);
7599         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7600         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
7601         return (long)ret_conv;
7602 }
7603
7604 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
7605         if ((_res & 1) != 0) return;
7606         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7607         FREE((void*)_res);
7608         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
7609 }
7610
7611 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
7612         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
7613         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7614         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
7615         return (long)ret_conv;
7616 }
7617
7618 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
7619         LDKChannelReestablish o_conv;
7620         o_conv.inner = (void*)(o & (~1));
7621         o_conv.is_owned = (o & 1) || (o == 0);
7622         o_conv = ChannelReestablish_clone(&o_conv);
7623         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7624         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
7625         return (long)ret_conv;
7626 }
7627
7628 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
7629         LDKDecodeError e_conv;
7630         e_conv.inner = (void*)(e & (~1));
7631         e_conv.is_owned = (e & 1) || (e == 0);
7632         e_conv = DecodeError_clone(&e_conv);
7633         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7634         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
7635         return (long)ret_conv;
7636 }
7637
7638 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
7639         if ((_res & 1) != 0) return;
7640         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
7641         FREE((void*)_res);
7642         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
7643 }
7644
7645 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
7646         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
7647         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7648         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
7649         return (long)ret_conv;
7650 }
7651
7652 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
7653         LDKClosingSigned o_conv;
7654         o_conv.inner = (void*)(o & (~1));
7655         o_conv.is_owned = (o & 1) || (o == 0);
7656         o_conv = ClosingSigned_clone(&o_conv);
7657         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7658         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
7659         return (long)ret_conv;
7660 }
7661
7662 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
7663         LDKDecodeError e_conv;
7664         e_conv.inner = (void*)(e & (~1));
7665         e_conv.is_owned = (e & 1) || (e == 0);
7666         e_conv = DecodeError_clone(&e_conv);
7667         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7668         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
7669         return (long)ret_conv;
7670 }
7671
7672 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
7673         if ((_res & 1) != 0) return;
7674         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7675         FREE((void*)_res);
7676         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
7677 }
7678
7679 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
7680         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
7681         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7682         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
7683         return (long)ret_conv;
7684 }
7685
7686 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
7687         LDKCommitmentSigned o_conv;
7688         o_conv.inner = (void*)(o & (~1));
7689         o_conv.is_owned = (o & 1) || (o == 0);
7690         o_conv = CommitmentSigned_clone(&o_conv);
7691         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7692         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
7693         return (long)ret_conv;
7694 }
7695
7696 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
7697         LDKDecodeError e_conv;
7698         e_conv.inner = (void*)(e & (~1));
7699         e_conv.is_owned = (e & 1) || (e == 0);
7700         e_conv = DecodeError_clone(&e_conv);
7701         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7702         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
7703         return (long)ret_conv;
7704 }
7705
7706 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
7707         if ((_res & 1) != 0) return;
7708         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7709         FREE((void*)_res);
7710         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
7711 }
7712
7713 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
7714         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
7715         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7716         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
7717         return (long)ret_conv;
7718 }
7719
7720 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
7721         LDKFundingCreated o_conv;
7722         o_conv.inner = (void*)(o & (~1));
7723         o_conv.is_owned = (o & 1) || (o == 0);
7724         o_conv = FundingCreated_clone(&o_conv);
7725         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7726         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
7727         return (long)ret_conv;
7728 }
7729
7730 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
7731         LDKDecodeError e_conv;
7732         e_conv.inner = (void*)(e & (~1));
7733         e_conv.is_owned = (e & 1) || (e == 0);
7734         e_conv = DecodeError_clone(&e_conv);
7735         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7736         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
7737         return (long)ret_conv;
7738 }
7739
7740 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
7741         if ((_res & 1) != 0) return;
7742         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7743         FREE((void*)_res);
7744         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
7745 }
7746
7747 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
7748         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
7749         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7750         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
7751         return (long)ret_conv;
7752 }
7753
7754 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
7755         LDKFundingSigned o_conv;
7756         o_conv.inner = (void*)(o & (~1));
7757         o_conv.is_owned = (o & 1) || (o == 0);
7758         o_conv = FundingSigned_clone(&o_conv);
7759         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7760         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
7761         return (long)ret_conv;
7762 }
7763
7764 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
7765         LDKDecodeError e_conv;
7766         e_conv.inner = (void*)(e & (~1));
7767         e_conv.is_owned = (e & 1) || (e == 0);
7768         e_conv = DecodeError_clone(&e_conv);
7769         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7770         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
7771         return (long)ret_conv;
7772 }
7773
7774 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
7775         if ((_res & 1) != 0) return;
7776         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7777         FREE((void*)_res);
7778         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
7779 }
7780
7781 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
7782         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
7783         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7784         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
7785         return (long)ret_conv;
7786 }
7787
7788 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
7789         LDKFundingLocked o_conv;
7790         o_conv.inner = (void*)(o & (~1));
7791         o_conv.is_owned = (o & 1) || (o == 0);
7792         o_conv = FundingLocked_clone(&o_conv);
7793         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7794         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
7795         return (long)ret_conv;
7796 }
7797
7798 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
7799         LDKDecodeError e_conv;
7800         e_conv.inner = (void*)(e & (~1));
7801         e_conv.is_owned = (e & 1) || (e == 0);
7802         e_conv = DecodeError_clone(&e_conv);
7803         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7804         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
7805         return (long)ret_conv;
7806 }
7807
7808 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
7809         if ((_res & 1) != 0) return;
7810         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7811         FREE((void*)_res);
7812         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
7813 }
7814
7815 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
7816         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
7817         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7818         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
7819         return (long)ret_conv;
7820 }
7821
7822 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
7823         LDKInit o_conv;
7824         o_conv.inner = (void*)(o & (~1));
7825         o_conv.is_owned = (o & 1) || (o == 0);
7826         o_conv = Init_clone(&o_conv);
7827         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7828         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
7829         return (long)ret_conv;
7830 }
7831
7832 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
7833         LDKDecodeError e_conv;
7834         e_conv.inner = (void*)(e & (~1));
7835         e_conv.is_owned = (e & 1) || (e == 0);
7836         e_conv = DecodeError_clone(&e_conv);
7837         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7838         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
7839         return (long)ret_conv;
7840 }
7841
7842 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
7843         if ((_res & 1) != 0) return;
7844         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
7845         FREE((void*)_res);
7846         CResult_InitDecodeErrorZ_free(_res_conv);
7847 }
7848
7849 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
7850         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
7851         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7852         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
7853         return (long)ret_conv;
7854 }
7855
7856 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
7857         LDKOpenChannel o_conv;
7858         o_conv.inner = (void*)(o & (~1));
7859         o_conv.is_owned = (o & 1) || (o == 0);
7860         o_conv = OpenChannel_clone(&o_conv);
7861         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7862         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
7863         return (long)ret_conv;
7864 }
7865
7866 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
7867         LDKDecodeError e_conv;
7868         e_conv.inner = (void*)(e & (~1));
7869         e_conv.is_owned = (e & 1) || (e == 0);
7870         e_conv = DecodeError_clone(&e_conv);
7871         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7872         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
7873         return (long)ret_conv;
7874 }
7875
7876 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
7877         if ((_res & 1) != 0) return;
7878         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7879         FREE((void*)_res);
7880         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
7881 }
7882
7883 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
7884         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
7885         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7886         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
7887         return (long)ret_conv;
7888 }
7889
7890 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
7891         LDKRevokeAndACK o_conv;
7892         o_conv.inner = (void*)(o & (~1));
7893         o_conv.is_owned = (o & 1) || (o == 0);
7894         o_conv = RevokeAndACK_clone(&o_conv);
7895         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7896         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
7897         return (long)ret_conv;
7898 }
7899
7900 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
7901         LDKDecodeError e_conv;
7902         e_conv.inner = (void*)(e & (~1));
7903         e_conv.is_owned = (e & 1) || (e == 0);
7904         e_conv = DecodeError_clone(&e_conv);
7905         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7906         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
7907         return (long)ret_conv;
7908 }
7909
7910 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
7911         if ((_res & 1) != 0) return;
7912         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
7913         FREE((void*)_res);
7914         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
7915 }
7916
7917 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
7918         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
7919         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7920         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
7921         return (long)ret_conv;
7922 }
7923
7924 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
7925         LDKShutdown o_conv;
7926         o_conv.inner = (void*)(o & (~1));
7927         o_conv.is_owned = (o & 1) || (o == 0);
7928         o_conv = Shutdown_clone(&o_conv);
7929         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
7930         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
7931         return (long)ret_conv;
7932 }
7933
7934 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
7935         LDKDecodeError e_conv;
7936         e_conv.inner = (void*)(e & (~1));
7937         e_conv.is_owned = (e & 1) || (e == 0);
7938         e_conv = DecodeError_clone(&e_conv);
7939         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
7940         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
7941         return (long)ret_conv;
7942 }
7943
7944 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
7945         if ((_res & 1) != 0) return;
7946         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
7947         FREE((void*)_res);
7948         CResult_ShutdownDecodeErrorZ_free(_res_conv);
7949 }
7950
7951 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
7952         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
7953         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
7954         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
7955         return (long)ret_conv;
7956 }
7957
7958 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
7959         LDKUpdateFailHTLC o_conv;
7960         o_conv.inner = (void*)(o & (~1));
7961         o_conv.is_owned = (o & 1) || (o == 0);
7962         o_conv = UpdateFailHTLC_clone(&o_conv);
7963         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
7964         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
7965         return (long)ret_conv;
7966 }
7967
7968 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
7969         LDKDecodeError e_conv;
7970         e_conv.inner = (void*)(e & (~1));
7971         e_conv.is_owned = (e & 1) || (e == 0);
7972         e_conv = DecodeError_clone(&e_conv);
7973         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
7974         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
7975         return (long)ret_conv;
7976 }
7977
7978 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
7979         if ((_res & 1) != 0) return;
7980         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
7981         FREE((void*)_res);
7982         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
7983 }
7984
7985 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
7986         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
7987         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
7988         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
7989         return (long)ret_conv;
7990 }
7991
7992 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
7993         LDKUpdateFailMalformedHTLC o_conv;
7994         o_conv.inner = (void*)(o & (~1));
7995         o_conv.is_owned = (o & 1) || (o == 0);
7996         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
7997         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
7998         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
7999         return (long)ret_conv;
8000 }
8001
8002 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
8003         LDKDecodeError e_conv;
8004         e_conv.inner = (void*)(e & (~1));
8005         e_conv.is_owned = (e & 1) || (e == 0);
8006         e_conv = DecodeError_clone(&e_conv);
8007         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8008         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
8009         return (long)ret_conv;
8010 }
8011
8012 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
8013         if ((_res & 1) != 0) return;
8014         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8015         FREE((void*)_res);
8016         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
8017 }
8018
8019 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
8020         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
8021         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8022         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
8023         return (long)ret_conv;
8024 }
8025
8026 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
8027         LDKUpdateFee o_conv;
8028         o_conv.inner = (void*)(o & (~1));
8029         o_conv.is_owned = (o & 1) || (o == 0);
8030         o_conv = UpdateFee_clone(&o_conv);
8031         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8032         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
8033         return (long)ret_conv;
8034 }
8035
8036 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
8037         LDKDecodeError e_conv;
8038         e_conv.inner = (void*)(e & (~1));
8039         e_conv.is_owned = (e & 1) || (e == 0);
8040         e_conv = DecodeError_clone(&e_conv);
8041         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8042         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
8043         return (long)ret_conv;
8044 }
8045
8046 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
8047         if ((_res & 1) != 0) return;
8048         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8049         FREE((void*)_res);
8050         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
8051 }
8052
8053 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
8054         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
8055         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8056         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
8057         return (long)ret_conv;
8058 }
8059
8060 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
8061         LDKUpdateFulfillHTLC o_conv;
8062         o_conv.inner = (void*)(o & (~1));
8063         o_conv.is_owned = (o & 1) || (o == 0);
8064         o_conv = UpdateFulfillHTLC_clone(&o_conv);
8065         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8066         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
8067         return (long)ret_conv;
8068 }
8069
8070 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
8071         LDKDecodeError e_conv;
8072         e_conv.inner = (void*)(e & (~1));
8073         e_conv.is_owned = (e & 1) || (e == 0);
8074         e_conv = DecodeError_clone(&e_conv);
8075         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8076         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
8077         return (long)ret_conv;
8078 }
8079
8080 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
8081         if ((_res & 1) != 0) return;
8082         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8083         FREE((void*)_res);
8084         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
8085 }
8086
8087 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
8088         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
8089         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8090         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
8091         return (long)ret_conv;
8092 }
8093
8094 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
8095         LDKUpdateAddHTLC o_conv;
8096         o_conv.inner = (void*)(o & (~1));
8097         o_conv.is_owned = (o & 1) || (o == 0);
8098         o_conv = UpdateAddHTLC_clone(&o_conv);
8099         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8100         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
8101         return (long)ret_conv;
8102 }
8103
8104 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
8105         LDKDecodeError e_conv;
8106         e_conv.inner = (void*)(e & (~1));
8107         e_conv.is_owned = (e & 1) || (e == 0);
8108         e_conv = DecodeError_clone(&e_conv);
8109         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8110         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
8111         return (long)ret_conv;
8112 }
8113
8114 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
8115         if ((_res & 1) != 0) return;
8116         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8117         FREE((void*)_res);
8118         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
8119 }
8120
8121 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
8122         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
8123         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8124         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
8125         return (long)ret_conv;
8126 }
8127
8128 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
8129         LDKPing o_conv;
8130         o_conv.inner = (void*)(o & (~1));
8131         o_conv.is_owned = (o & 1) || (o == 0);
8132         o_conv = Ping_clone(&o_conv);
8133         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8134         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
8135         return (long)ret_conv;
8136 }
8137
8138 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
8139         LDKDecodeError e_conv;
8140         e_conv.inner = (void*)(e & (~1));
8141         e_conv.is_owned = (e & 1) || (e == 0);
8142         e_conv = DecodeError_clone(&e_conv);
8143         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8144         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
8145         return (long)ret_conv;
8146 }
8147
8148 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
8149         if ((_res & 1) != 0) return;
8150         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
8151         FREE((void*)_res);
8152         CResult_PingDecodeErrorZ_free(_res_conv);
8153 }
8154
8155 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
8156         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
8157         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8158         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
8159         return (long)ret_conv;
8160 }
8161
8162 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
8163         LDKPong o_conv;
8164         o_conv.inner = (void*)(o & (~1));
8165         o_conv.is_owned = (o & 1) || (o == 0);
8166         o_conv = Pong_clone(&o_conv);
8167         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8168         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
8169         return (long)ret_conv;
8170 }
8171
8172 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
8173         LDKDecodeError e_conv;
8174         e_conv.inner = (void*)(e & (~1));
8175         e_conv.is_owned = (e & 1) || (e == 0);
8176         e_conv = DecodeError_clone(&e_conv);
8177         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8178         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
8179         return (long)ret_conv;
8180 }
8181
8182 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
8183         if ((_res & 1) != 0) return;
8184         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
8185         FREE((void*)_res);
8186         CResult_PongDecodeErrorZ_free(_res_conv);
8187 }
8188
8189 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
8190         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
8191         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8192         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
8193         return (long)ret_conv;
8194 }
8195
8196 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8197         LDKUnsignedChannelAnnouncement o_conv;
8198         o_conv.inner = (void*)(o & (~1));
8199         o_conv.is_owned = (o & 1) || (o == 0);
8200         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
8201         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8202         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
8203         return (long)ret_conv;
8204 }
8205
8206 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8207         LDKDecodeError e_conv;
8208         e_conv.inner = (void*)(e & (~1));
8209         e_conv.is_owned = (e & 1) || (e == 0);
8210         e_conv = DecodeError_clone(&e_conv);
8211         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8212         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
8213         return (long)ret_conv;
8214 }
8215
8216 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8217         if ((_res & 1) != 0) return;
8218         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8219         FREE((void*)_res);
8220         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
8221 }
8222
8223 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8224         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8225         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8226         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8227         return (long)ret_conv;
8228 }
8229
8230 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8231         LDKChannelAnnouncement o_conv;
8232         o_conv.inner = (void*)(o & (~1));
8233         o_conv.is_owned = (o & 1) || (o == 0);
8234         o_conv = ChannelAnnouncement_clone(&o_conv);
8235         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8236         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
8237         return (long)ret_conv;
8238 }
8239
8240 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8241         LDKDecodeError e_conv;
8242         e_conv.inner = (void*)(e & (~1));
8243         e_conv.is_owned = (e & 1) || (e == 0);
8244         e_conv = DecodeError_clone(&e_conv);
8245         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8246         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
8247         return (long)ret_conv;
8248 }
8249
8250 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8251         if ((_res & 1) != 0) return;
8252         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8253         FREE((void*)_res);
8254         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
8255 }
8256
8257 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8258         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8259         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8260         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8261         return (long)ret_conv;
8262 }
8263
8264 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8265         LDKUnsignedChannelUpdate o_conv;
8266         o_conv.inner = (void*)(o & (~1));
8267         o_conv.is_owned = (o & 1) || (o == 0);
8268         o_conv = UnsignedChannelUpdate_clone(&o_conv);
8269         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8270         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
8271         return (long)ret_conv;
8272 }
8273
8274 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
8275         LDKDecodeError e_conv;
8276         e_conv.inner = (void*)(e & (~1));
8277         e_conv.is_owned = (e & 1) || (e == 0);
8278         e_conv = DecodeError_clone(&e_conv);
8279         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8280         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
8281         return (long)ret_conv;
8282 }
8283
8284 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8285         if ((_res & 1) != 0) return;
8286         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8287         FREE((void*)_res);
8288         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
8289 }
8290
8291 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8292         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
8293         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8294         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
8295         return (long)ret_conv;
8296 }
8297
8298 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8299         LDKChannelUpdate o_conv;
8300         o_conv.inner = (void*)(o & (~1));
8301         o_conv.is_owned = (o & 1) || (o == 0);
8302         o_conv = ChannelUpdate_clone(&o_conv);
8303         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8304         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
8305         return (long)ret_conv;
8306 }
8307
8308 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
8309         LDKDecodeError e_conv;
8310         e_conv.inner = (void*)(e & (~1));
8311         e_conv.is_owned = (e & 1) || (e == 0);
8312         e_conv = DecodeError_clone(&e_conv);
8313         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8314         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
8315         return (long)ret_conv;
8316 }
8317
8318 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8319         if ((_res & 1) != 0) return;
8320         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8321         FREE((void*)_res);
8322         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
8323 }
8324
8325 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8326         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
8327         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8328         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
8329         return (long)ret_conv;
8330 }
8331
8332 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
8333         LDKErrorMessage o_conv;
8334         o_conv.inner = (void*)(o & (~1));
8335         o_conv.is_owned = (o & 1) || (o == 0);
8336         o_conv = ErrorMessage_clone(&o_conv);
8337         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8338         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
8339         return (long)ret_conv;
8340 }
8341
8342 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
8343         LDKDecodeError e_conv;
8344         e_conv.inner = (void*)(e & (~1));
8345         e_conv.is_owned = (e & 1) || (e == 0);
8346         e_conv = DecodeError_clone(&e_conv);
8347         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8348         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
8349         return (long)ret_conv;
8350 }
8351
8352 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
8353         if ((_res & 1) != 0) return;
8354         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
8355         FREE((void*)_res);
8356         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
8357 }
8358
8359 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
8360         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
8361         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8362         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
8363         return (long)ret_conv;
8364 }
8365
8366 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8367         LDKUnsignedNodeAnnouncement o_conv;
8368         o_conv.inner = (void*)(o & (~1));
8369         o_conv.is_owned = (o & 1) || (o == 0);
8370         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
8371         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8372         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
8373         return (long)ret_conv;
8374 }
8375
8376 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8377         LDKDecodeError e_conv;
8378         e_conv.inner = (void*)(e & (~1));
8379         e_conv.is_owned = (e & 1) || (e == 0);
8380         e_conv = DecodeError_clone(&e_conv);
8381         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8382         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
8383         return (long)ret_conv;
8384 }
8385
8386 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8387         if ((_res & 1) != 0) return;
8388         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8389         FREE((void*)_res);
8390         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
8391 }
8392
8393 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8394         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
8395         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8396         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
8397         return (long)ret_conv;
8398 }
8399
8400 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8401         LDKNodeAnnouncement o_conv;
8402         o_conv.inner = (void*)(o & (~1));
8403         o_conv.is_owned = (o & 1) || (o == 0);
8404         o_conv = NodeAnnouncement_clone(&o_conv);
8405         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8406         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
8407         return (long)ret_conv;
8408 }
8409
8410 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8411         LDKDecodeError e_conv;
8412         e_conv.inner = (void*)(e & (~1));
8413         e_conv.is_owned = (e & 1) || (e == 0);
8414         e_conv = DecodeError_clone(&e_conv);
8415         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8416         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
8417         return (long)ret_conv;
8418 }
8419
8420 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8421         if ((_res & 1) != 0) return;
8422         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8423         FREE((void*)_res);
8424         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
8425 }
8426
8427 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8428         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
8429         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8430         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
8431         return (long)ret_conv;
8432 }
8433
8434 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
8435         LDKQueryShortChannelIds o_conv;
8436         o_conv.inner = (void*)(o & (~1));
8437         o_conv.is_owned = (o & 1) || (o == 0);
8438         o_conv = QueryShortChannelIds_clone(&o_conv);
8439         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8440         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
8441         return (long)ret_conv;
8442 }
8443
8444 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
8445         LDKDecodeError e_conv;
8446         e_conv.inner = (void*)(e & (~1));
8447         e_conv.is_owned = (e & 1) || (e == 0);
8448         e_conv = DecodeError_clone(&e_conv);
8449         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8450         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
8451         return (long)ret_conv;
8452 }
8453
8454 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
8455         if ((_res & 1) != 0) return;
8456         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
8457         FREE((void*)_res);
8458         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
8459 }
8460
8461 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
8462         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
8463         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8464         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
8465         return (long)ret_conv;
8466 }
8467
8468 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
8469         LDKReplyShortChannelIdsEnd o_conv;
8470         o_conv.inner = (void*)(o & (~1));
8471         o_conv.is_owned = (o & 1) || (o == 0);
8472         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
8473         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8474         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
8475         return (long)ret_conv;
8476 }
8477
8478 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
8479         LDKDecodeError e_conv;
8480         e_conv.inner = (void*)(e & (~1));
8481         e_conv.is_owned = (e & 1) || (e == 0);
8482         e_conv = DecodeError_clone(&e_conv);
8483         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8484         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
8485         return (long)ret_conv;
8486 }
8487
8488 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
8489         if ((_res & 1) != 0) return;
8490         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
8491         FREE((void*)_res);
8492         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
8493 }
8494
8495 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
8496         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
8497         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8498         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
8499         return (long)ret_conv;
8500 }
8501
8502 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
8503         LDKQueryChannelRange o_conv;
8504         o_conv.inner = (void*)(o & (~1));
8505         o_conv.is_owned = (o & 1) || (o == 0);
8506         o_conv = QueryChannelRange_clone(&o_conv);
8507         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8508         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
8509         return (long)ret_conv;
8510 }
8511
8512 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
8513         LDKDecodeError e_conv;
8514         e_conv.inner = (void*)(e & (~1));
8515         e_conv.is_owned = (e & 1) || (e == 0);
8516         e_conv = DecodeError_clone(&e_conv);
8517         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8518         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
8519         return (long)ret_conv;
8520 }
8521
8522 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
8523         if ((_res & 1) != 0) return;
8524         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8525         FREE((void*)_res);
8526         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
8527 }
8528
8529 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8530         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
8531         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8532         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
8533         return (long)ret_conv;
8534 }
8535
8536 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
8537         LDKReplyChannelRange o_conv;
8538         o_conv.inner = (void*)(o & (~1));
8539         o_conv.is_owned = (o & 1) || (o == 0);
8540         o_conv = ReplyChannelRange_clone(&o_conv);
8541         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8542         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
8543         return (long)ret_conv;
8544 }
8545
8546 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
8547         LDKDecodeError e_conv;
8548         e_conv.inner = (void*)(e & (~1));
8549         e_conv.is_owned = (e & 1) || (e == 0);
8550         e_conv = DecodeError_clone(&e_conv);
8551         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8552         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
8553         return (long)ret_conv;
8554 }
8555
8556 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
8557         if ((_res & 1) != 0) return;
8558         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8559         FREE((void*)_res);
8560         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
8561 }
8562
8563 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8564         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
8565         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8566         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
8567         return (long)ret_conv;
8568 }
8569
8570 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
8571         LDKGossipTimestampFilter o_conv;
8572         o_conv.inner = (void*)(o & (~1));
8573         o_conv.is_owned = (o & 1) || (o == 0);
8574         o_conv = GossipTimestampFilter_clone(&o_conv);
8575         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8576         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
8577         return (long)ret_conv;
8578 }
8579
8580 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
8581         LDKDecodeError e_conv;
8582         e_conv.inner = (void*)(e & (~1));
8583         e_conv.is_owned = (e & 1) || (e == 0);
8584         e_conv = DecodeError_clone(&e_conv);
8585         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8586         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
8587         return (long)ret_conv;
8588 }
8589
8590 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
8591         if ((_res & 1) != 0) return;
8592         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
8593         FREE((void*)_res);
8594         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
8595 }
8596
8597 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
8598         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
8599         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8600         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
8601         return (long)ret_conv;
8602 }
8603
8604 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8605         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8606         FREE((void*)o);
8607         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8608         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8609         return (long)ret_conv;
8610 }
8611
8612 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8613         LDKDecodeError e_conv;
8614         e_conv.inner = (void*)(e & (~1));
8615         e_conv.is_owned = (e & 1) || (e == 0);
8616         e_conv = DecodeError_clone(&e_conv);
8617         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8618         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8619         return (long)ret_conv;
8620 }
8621
8622 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8623         if ((_res & 1) != 0) return;
8624         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8625         FREE((void*)_res);
8626         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8627 }
8628
8629 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8630         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8631         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8632         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8633         return (long)ret_conv;
8634 }
8635
8636 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
8637         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8638         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8639         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8640         return (long)ret_ref;
8641 }
8642
8643 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
8644         LDKSignature a_ref;
8645         CHECK(*((uint32_t*)a) == 64);
8646         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
8647         LDKCVec_SignatureZ b_constr;
8648         b_constr.datalen = *((uint32_t*)b);
8649         if (b_constr.datalen > 0)
8650                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8651         else
8652                 b_constr.data = NULL;
8653         int8_tArray* b_vals = (int8_tArray*)(b + 4);
8654         for (size_t m = 0; m < b_constr.datalen; m++) {
8655                 int8_tArray b_conv_12 = b_vals[m];
8656                 LDKSignature b_conv_12_ref;
8657                 CHECK(*((uint32_t*)b_conv_12) == 64);
8658                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
8659                 b_constr.data[m] = b_conv_12_ref;
8660         }
8661         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8662         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8663         return (long)ret_ref;
8664 }
8665
8666 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
8667         if ((_res & 1) != 0) return;
8668         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8669         FREE((void*)_res);
8670         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8671 }
8672
8673 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
8674         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8675         FREE((void*)o);
8676         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8677         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8678         return (long)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
8682         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8683         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8684         return (long)ret_conv;
8685 }
8686
8687 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
8688         if ((_res & 1) != 0) return;
8689         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8690         FREE((void*)_res);
8691         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8692 }
8693
8694 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
8695         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8696         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8697         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8698         return (long)ret_conv;
8699 }
8700
8701 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
8702         LDKSignature o_ref;
8703         CHECK(*((uint32_t*)o) == 64);
8704         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
8705         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8706         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8707         return (long)ret_conv;
8708 }
8709
8710 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
8711         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8712         *ret_conv = CResult_SignatureNoneZ_err();
8713         return (long)ret_conv;
8714 }
8715
8716 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
8717         if ((_res & 1) != 0) return;
8718         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8719         FREE((void*)_res);
8720         CResult_SignatureNoneZ_free(_res_conv);
8721 }
8722
8723 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
8724         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8725         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8726         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8727         return (long)ret_conv;
8728 }
8729
8730 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
8731         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8732         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8733         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8734         return (long)ret_conv;
8735 }
8736
8737 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
8738         LDKDecodeError e_conv;
8739         e_conv.inner = (void*)(e & (~1));
8740         e_conv.is_owned = (e & 1) || (e == 0);
8741         e_conv = DecodeError_clone(&e_conv);
8742         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8743         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8744         return (long)ret_conv;
8745 }
8746
8747 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
8748         if ((_res & 1) != 0) return;
8749         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8750         FREE((void*)_res);
8751         CResult_SignDecodeErrorZ_free(_res_conv);
8752 }
8753
8754 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
8755         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8756         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8757         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8758         return (long)ret_conv;
8759 }
8760
8761 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
8762         LDKCVec_CVec_u8ZZ _res_constr;
8763         _res_constr.datalen = *((uint32_t*)_res);
8764         if (_res_constr.datalen > 0)
8765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8766         else
8767                 _res_constr.data = NULL;
8768         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8769         for (size_t m = 0; m < _res_constr.datalen; m++) {
8770                 int8_tArray _res_conv_12 = _res_vals[m];
8771                 LDKCVec_u8Z _res_conv_12_ref;
8772                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8773                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8774                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8775                 _res_constr.data[m] = _res_conv_12_ref;
8776         }
8777         CVec_CVec_u8ZZ_free(_res_constr);
8778 }
8779
8780 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
8781         LDKCVec_CVec_u8ZZ o_constr;
8782         o_constr.datalen = *((uint32_t*)o);
8783         if (o_constr.datalen > 0)
8784                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8785         else
8786                 o_constr.data = NULL;
8787         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8788         for (size_t m = 0; m < o_constr.datalen; m++) {
8789                 int8_tArray o_conv_12 = o_vals[m];
8790                 LDKCVec_u8Z o_conv_12_ref;
8791                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
8792                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8793                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
8794                 o_constr.data[m] = o_conv_12_ref;
8795         }
8796         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8797         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8798         return (long)ret_conv;
8799 }
8800
8801 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
8802         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8803         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8804         return (long)ret_conv;
8805 }
8806
8807 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
8808         if ((_res & 1) != 0) return;
8809         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8810         FREE((void*)_res);
8811         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8812 }
8813
8814 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
8815         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8816         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8817         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8818         return (long)ret_conv;
8819 }
8820
8821 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
8822         LDKInMemorySigner o_conv;
8823         o_conv.inner = (void*)(o & (~1));
8824         o_conv.is_owned = (o & 1) || (o == 0);
8825         o_conv = InMemorySigner_clone(&o_conv);
8826         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8827         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8828         return (long)ret_conv;
8829 }
8830
8831 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
8832         LDKDecodeError e_conv;
8833         e_conv.inner = (void*)(e & (~1));
8834         e_conv.is_owned = (e & 1) || (e == 0);
8835         e_conv = DecodeError_clone(&e_conv);
8836         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8837         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8838         return (long)ret_conv;
8839 }
8840
8841 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
8842         if ((_res & 1) != 0) return;
8843         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8844         FREE((void*)_res);
8845         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8846 }
8847
8848 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
8849         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8850         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8851         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8852         return (long)ret_conv;
8853 }
8854
8855 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
8856         LDKCVec_TxOutZ _res_constr;
8857         _res_constr.datalen = *((uint32_t*)_res);
8858         if (_res_constr.datalen > 0)
8859                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8860         else
8861                 _res_constr.data = NULL;
8862         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8863         for (size_t h = 0; h < _res_constr.datalen; h++) {
8864                 uint32_t _res_conv_7 = _res_vals[h];
8865                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8866                 FREE((void*)_res_conv_7);
8867                 _res_constr.data[h] = _res_conv_7_conv;
8868         }
8869         CVec_TxOutZ_free(_res_constr);
8870 }
8871
8872 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
8873         LDKTransaction o_ref;
8874         o_ref.datalen = *((uint32_t*)o);
8875         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8876         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
8877         o_ref.data_is_owned = true;
8878         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8879         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8880         return (long)ret_conv;
8881 }
8882
8883 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
8884         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8885         *ret_conv = CResult_TransactionNoneZ_err();
8886         return (long)ret_conv;
8887 }
8888
8889 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
8890         if ((_res & 1) != 0) return;
8891         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8892         FREE((void*)_res);
8893         CResult_TransactionNoneZ_free(_res_conv);
8894 }
8895
8896 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
8897         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8898         *ret_conv = CResult_NoneErrorZ_ok();
8899         return (long)ret_conv;
8900 }
8901
8902 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
8903         LDKIOError e_conv = LDKIOError_from_js(e);
8904         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8905         *ret_conv = CResult_NoneErrorZ_err(e_conv);
8906         return (long)ret_conv;
8907 }
8908
8909 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
8910         if ((_res & 1) != 0) return;
8911         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
8912         FREE((void*)_res);
8913         CResult_NoneErrorZ_free(_res_conv);
8914 }
8915
8916 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
8917         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
8918         _res_constr.datalen = *((uint32_t*)_res);
8919         if (_res_constr.datalen > 0)
8920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8921         else
8922                 _res_constr.data = NULL;
8923         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8924         for (size_t m = 0; m < _res_constr.datalen; m++) {
8925                 uint32_t _res_conv_38 = _res_vals[m];
8926                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
8927                 FREE((void*)_res_conv_38);
8928                 _res_constr.data[m] = _res_conv_38_conv;
8929         }
8930         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
8931 }
8932
8933 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
8934         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
8935         o_constr.datalen = *((uint32_t*)o);
8936         if (o_constr.datalen > 0)
8937                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8938         else
8939                 o_constr.data = NULL;
8940         uint32_t* o_vals = (uint32_t*)(o + 4);
8941         for (size_t m = 0; m < o_constr.datalen; m++) {
8942                 uint32_t o_conv_38 = o_vals[m];
8943                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
8944                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
8945                 o_constr.data[m] = o_conv_38_conv;
8946         }
8947         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8948         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
8949         return (long)ret_conv;
8950 }
8951
8952 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
8953         LDKIOError e_conv = LDKIOError_from_js(e);
8954         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8955         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
8956         return (long)ret_conv;
8957 }
8958
8959 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
8960         if ((_res & 1) != 0) return;
8961         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
8962         FREE((void*)_res);
8963         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
8964 }
8965
8966 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
8967         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8968         *ret_conv = CResult_NoneAPIErrorZ_ok();
8969         return (long)ret_conv;
8970 }
8971
8972 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
8973         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8974         FREE((void*)e);
8975         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8976         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
8977         return (long)ret_conv;
8978 }
8979
8980 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
8981         if ((_res & 1) != 0) return;
8982         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
8983         FREE((void*)_res);
8984         CResult_NoneAPIErrorZ_free(_res_conv);
8985 }
8986
8987 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
8988         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
8989         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8990         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8991         return (long)ret_conv;
8992 }
8993
8994 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8995         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8996         _res_constr.datalen = *((uint32_t*)_res);
8997         if (_res_constr.datalen > 0)
8998                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8999         else
9000                 _res_constr.data = NULL;
9001         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9002         for (size_t w = 0; w < _res_constr.datalen; w++) {
9003                 uint32_t _res_conv_22 = _res_vals[w];
9004                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
9005                 FREE((void*)_res_conv_22);
9006                 _res_constr.data[w] = _res_conv_22_conv;
9007         }
9008         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
9009 }
9010
9011 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
9012         LDKCVec_APIErrorZ _res_constr;
9013         _res_constr.datalen = *((uint32_t*)_res);
9014         if (_res_constr.datalen > 0)
9015                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
9016         else
9017                 _res_constr.data = NULL;
9018         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9019         for (size_t k = 0; k < _res_constr.datalen; k++) {
9020                 uint32_t _res_conv_10 = _res_vals[k];
9021                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
9022                 FREE((void*)_res_conv_10);
9023                 _res_constr.data[k] = _res_conv_10_conv;
9024         }
9025         CVec_APIErrorZ_free(_res_constr);
9026 }
9027
9028 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
9029         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9030         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
9031         return (long)ret_conv;
9032 }
9033
9034 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
9035         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
9036         FREE((void*)e);
9037         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9038         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
9039         return (long)ret_conv;
9040 }
9041
9042 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
9043         if ((_res & 1) != 0) return;
9044         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9045         FREE((void*)_res);
9046         CResult_NonePaymentSendFailureZ_free(_res_conv);
9047 }
9048
9049 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
9050         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
9051         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9052         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
9053         return (long)ret_conv;
9054 }
9055
9056 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
9057         LDKCVec_ChannelMonitorZ _res_constr;
9058         _res_constr.datalen = *((uint32_t*)_res);
9059         if (_res_constr.datalen > 0)
9060                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
9061         else
9062                 _res_constr.data = NULL;
9063         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9064         for (size_t q = 0; q < _res_constr.datalen; q++) {
9065                 uint32_t _res_conv_16 = _res_vals[q];
9066                 LDKChannelMonitor _res_conv_16_conv;
9067                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9068                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9069                 _res_constr.data[q] = _res_conv_16_conv;
9070         }
9071         CVec_ChannelMonitorZ_free(_res_constr);
9072 }
9073
9074 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
9075         LDKThirtyTwoBytes a_ref;
9076         CHECK(*((uint32_t*)a) == 32);
9077         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9078         LDKChannelManager b_conv;
9079         b_conv.inner = (void*)(b & (~1));
9080         b_conv.is_owned = (b & 1) || (b == 0);
9081         // Warning: we need a move here but no clone is available for LDKChannelManager
9082         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
9083         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
9084         return (long)ret_ref;
9085 }
9086
9087 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
9088         if ((_res & 1) != 0) return;
9089         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
9090         FREE((void*)_res);
9091         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
9092 }
9093
9094 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
9095         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
9096         FREE((void*)o);
9097         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9098         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
9099         return (long)ret_conv;
9100 }
9101
9102 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
9103         LDKDecodeError e_conv;
9104         e_conv.inner = (void*)(e & (~1));
9105         e_conv.is_owned = (e & 1) || (e == 0);
9106         e_conv = DecodeError_clone(&e_conv);
9107         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9108         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
9109         return (long)ret_conv;
9110 }
9111
9112 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
9113         if ((_res & 1) != 0) return;
9114         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9115         FREE((void*)_res);
9116         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
9117 }
9118
9119 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
9120         if ((this_ptr & 1) != 0) return;
9121         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
9122         FREE((void*)this_ptr);
9123         Event_free(this_ptr_conv);
9124 }
9125
9126 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
9127         LDKEvent* orig_conv = (LDKEvent*)orig;
9128         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9129         *ret_copy = Event_clone(orig_conv);
9130         long ret_ref = (long)ret_copy;
9131         return ret_ref;
9132 }
9133
9134 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
9135         LDKEvent* obj_conv = (LDKEvent*)obj;
9136         LDKCVec_u8Z ret_var = Event_write(obj_conv);
9137         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9138         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9139         CVec_u8Z_free(ret_var);
9140         return ret_arr;
9141 }
9142
9143 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
9144         if ((this_ptr & 1) != 0) return;
9145         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
9146         FREE((void*)this_ptr);
9147         MessageSendEvent_free(this_ptr_conv);
9148 }
9149
9150 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
9151         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
9152         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9153         *ret_copy = MessageSendEvent_clone(orig_conv);
9154         long ret_ref = (long)ret_copy;
9155         return ret_ref;
9156 }
9157
9158 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
9159         if ((this_ptr & 1) != 0) return;
9160         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
9161         FREE((void*)this_ptr);
9162         MessageSendEventsProvider_free(this_ptr_conv);
9163 }
9164
9165 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
9166         if ((this_ptr & 1) != 0) return;
9167         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
9168         FREE((void*)this_ptr);
9169         EventsProvider_free(this_ptr_conv);
9170 }
9171
9172 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
9173         if ((this_ptr & 1) != 0) return;
9174         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
9175         FREE((void*)this_ptr);
9176         APIError_free(this_ptr_conv);
9177 }
9178
9179 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
9180         LDKAPIError* orig_conv = (LDKAPIError*)orig;
9181         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
9182         *ret_copy = APIError_clone(orig_conv);
9183         long ret_ref = (long)ret_copy;
9184         return ret_ref;
9185 }
9186
9187 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
9188         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
9189         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
9190         return ret_conv;
9191 }
9192
9193 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
9194         uint32_t ret_conv = LDKLevel_to_js(Level_max());
9195         return ret_conv;
9196 }
9197
9198 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
9199         if ((this_ptr & 1) != 0) return;
9200         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
9201         FREE((void*)this_ptr);
9202         Logger_free(this_ptr_conv);
9203 }
9204
9205 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
9206         LDKChannelHandshakeConfig this_obj_conv;
9207         this_obj_conv.inner = (void*)(this_obj & (~1));
9208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9209         ChannelHandshakeConfig_free(this_obj_conv);
9210 }
9211
9212 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
9213         LDKChannelHandshakeConfig this_ptr_conv;
9214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9215         this_ptr_conv.is_owned = false;
9216         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
9217         return ret_val;
9218 }
9219
9220 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
9221         LDKChannelHandshakeConfig this_ptr_conv;
9222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9223         this_ptr_conv.is_owned = false;
9224         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
9225 }
9226
9227 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
9228         LDKChannelHandshakeConfig this_ptr_conv;
9229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9230         this_ptr_conv.is_owned = false;
9231         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
9232         return ret_val;
9233 }
9234
9235 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
9236         LDKChannelHandshakeConfig this_ptr_conv;
9237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9238         this_ptr_conv.is_owned = false;
9239         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
9240 }
9241
9242 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
9243         LDKChannelHandshakeConfig this_ptr_conv;
9244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9245         this_ptr_conv.is_owned = false;
9246         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
9247         return ret_val;
9248 }
9249
9250 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9251         LDKChannelHandshakeConfig this_ptr_conv;
9252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9253         this_ptr_conv.is_owned = false;
9254         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
9255 }
9256
9257 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) {
9258         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
9259         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9260         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9261         long ret_ref = (long)ret_var.inner;
9262         if (ret_var.is_owned) {
9263                 ret_ref |= 1;
9264         }
9265         return ret_ref;
9266 }
9267
9268 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
9269         LDKChannelHandshakeConfig orig_conv;
9270         orig_conv.inner = (void*)(orig & (~1));
9271         orig_conv.is_owned = false;
9272         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
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 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
9283         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
9284         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9285         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9286         long ret_ref = (long)ret_var.inner;
9287         if (ret_var.is_owned) {
9288                 ret_ref |= 1;
9289         }
9290         return ret_ref;
9291 }
9292
9293 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
9294         LDKChannelHandshakeLimits this_obj_conv;
9295         this_obj_conv.inner = (void*)(this_obj & (~1));
9296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9297         ChannelHandshakeLimits_free(this_obj_conv);
9298 }
9299
9300 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
9301         LDKChannelHandshakeLimits this_ptr_conv;
9302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9303         this_ptr_conv.is_owned = false;
9304         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
9305         return ret_val;
9306 }
9307
9308 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
9309         LDKChannelHandshakeLimits this_ptr_conv;
9310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9311         this_ptr_conv.is_owned = false;
9312         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
9313 }
9314
9315 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
9316         LDKChannelHandshakeLimits this_ptr_conv;
9317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9318         this_ptr_conv.is_owned = false;
9319         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
9320         return ret_val;
9321 }
9322
9323 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9324         LDKChannelHandshakeLimits this_ptr_conv;
9325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9326         this_ptr_conv.is_owned = false;
9327         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
9328 }
9329
9330 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
9331         LDKChannelHandshakeLimits this_ptr_conv;
9332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9333         this_ptr_conv.is_owned = false;
9334         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
9335         return ret_val;
9336 }
9337
9338 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
9339         LDKChannelHandshakeLimits this_ptr_conv;
9340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9341         this_ptr_conv.is_owned = false;
9342         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9343 }
9344
9345 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
9346         LDKChannelHandshakeLimits this_ptr_conv;
9347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9348         this_ptr_conv.is_owned = false;
9349         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
9350         return ret_val;
9351 }
9352
9353 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
9354         LDKChannelHandshakeLimits this_ptr_conv;
9355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9356         this_ptr_conv.is_owned = false;
9357         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
9358 }
9359
9360 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
9361         LDKChannelHandshakeLimits this_ptr_conv;
9362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9363         this_ptr_conv.is_owned = false;
9364         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
9365         return ret_val;
9366 }
9367
9368 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
9369         LDKChannelHandshakeLimits this_ptr_conv;
9370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9371         this_ptr_conv.is_owned = false;
9372         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
9373 }
9374
9375 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
9376         LDKChannelHandshakeLimits this_ptr_conv;
9377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9378         this_ptr_conv.is_owned = false;
9379         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
9380         return ret_val;
9381 }
9382
9383 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
9384         LDKChannelHandshakeLimits this_ptr_conv;
9385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9386         this_ptr_conv.is_owned = false;
9387         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
9388 }
9389
9390 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
9391         LDKChannelHandshakeLimits this_ptr_conv;
9392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9393         this_ptr_conv.is_owned = false;
9394         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
9395         return ret_val;
9396 }
9397
9398 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
9399         LDKChannelHandshakeLimits this_ptr_conv;
9400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9401         this_ptr_conv.is_owned = false;
9402         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
9403 }
9404
9405 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
9406         LDKChannelHandshakeLimits this_ptr_conv;
9407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9408         this_ptr_conv.is_owned = false;
9409         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
9410         return ret_val;
9411 }
9412
9413 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
9414         LDKChannelHandshakeLimits this_ptr_conv;
9415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9416         this_ptr_conv.is_owned = false;
9417         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
9418 }
9419
9420 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
9421         LDKChannelHandshakeLimits this_ptr_conv;
9422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9423         this_ptr_conv.is_owned = false;
9424         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
9425         return ret_val;
9426 }
9427
9428 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
9429         LDKChannelHandshakeLimits this_ptr_conv;
9430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9431         this_ptr_conv.is_owned = false;
9432         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
9433 }
9434
9435 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
9436         LDKChannelHandshakeLimits this_ptr_conv;
9437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9438         this_ptr_conv.is_owned = false;
9439         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
9440         return ret_val;
9441 }
9442
9443 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
9444         LDKChannelHandshakeLimits this_ptr_conv;
9445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9446         this_ptr_conv.is_owned = false;
9447         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
9448 }
9449
9450 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) {
9451         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);
9452         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9453         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9454         long ret_ref = (long)ret_var.inner;
9455         if (ret_var.is_owned) {
9456                 ret_ref |= 1;
9457         }
9458         return ret_ref;
9459 }
9460
9461 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
9462         LDKChannelHandshakeLimits orig_conv;
9463         orig_conv.inner = (void*)(orig & (~1));
9464         orig_conv.is_owned = false;
9465         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
9466         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9467         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9468         long ret_ref = (long)ret_var.inner;
9469         if (ret_var.is_owned) {
9470                 ret_ref |= 1;
9471         }
9472         return ret_ref;
9473 }
9474
9475 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
9476         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
9477         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9478         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9479         long ret_ref = (long)ret_var.inner;
9480         if (ret_var.is_owned) {
9481                 ret_ref |= 1;
9482         }
9483         return ret_ref;
9484 }
9485
9486 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
9487         LDKChannelConfig this_obj_conv;
9488         this_obj_conv.inner = (void*)(this_obj & (~1));
9489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9490         ChannelConfig_free(this_obj_conv);
9491 }
9492
9493 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
9494         LDKChannelConfig this_ptr_conv;
9495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9496         this_ptr_conv.is_owned = false;
9497         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
9498         return ret_val;
9499 }
9500
9501 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
9502         LDKChannelConfig this_ptr_conv;
9503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9504         this_ptr_conv.is_owned = false;
9505         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
9506 }
9507
9508 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
9509         LDKChannelConfig this_ptr_conv;
9510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9511         this_ptr_conv.is_owned = false;
9512         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
9513         return ret_val;
9514 }
9515
9516 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
9517         LDKChannelConfig this_ptr_conv;
9518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9519         this_ptr_conv.is_owned = false;
9520         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
9521 }
9522
9523 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
9524         LDKChannelConfig this_ptr_conv;
9525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9526         this_ptr_conv.is_owned = false;
9527         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
9528         return ret_val;
9529 }
9530
9531 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
9532         LDKChannelConfig this_ptr_conv;
9533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9534         this_ptr_conv.is_owned = false;
9535         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
9536 }
9537
9538 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
9539         LDKChannelConfig this_ptr_conv;
9540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9541         this_ptr_conv.is_owned = false;
9542         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
9543         return ret_val;
9544 }
9545
9546 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
9547         LDKChannelConfig this_ptr_conv;
9548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9549         this_ptr_conv.is_owned = false;
9550         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
9551 }
9552
9553 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) {
9554         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
9555         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9556         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9557         long ret_ref = (long)ret_var.inner;
9558         if (ret_var.is_owned) {
9559                 ret_ref |= 1;
9560         }
9561         return ret_ref;
9562 }
9563
9564 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
9565         LDKChannelConfig orig_conv;
9566         orig_conv.inner = (void*)(orig & (~1));
9567         orig_conv.is_owned = false;
9568         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
9569         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9570         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9571         long ret_ref = (long)ret_var.inner;
9572         if (ret_var.is_owned) {
9573                 ret_ref |= 1;
9574         }
9575         return ret_ref;
9576 }
9577
9578 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
9579         LDKChannelConfig ret_var = ChannelConfig_default();
9580         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9581         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9582         long ret_ref = (long)ret_var.inner;
9583         if (ret_var.is_owned) {
9584                 ret_ref |= 1;
9585         }
9586         return ret_ref;
9587 }
9588
9589 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
9590         LDKChannelConfig obj_conv;
9591         obj_conv.inner = (void*)(obj & (~1));
9592         obj_conv.is_owned = false;
9593         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
9594         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9595         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9596         CVec_u8Z_free(ret_var);
9597         return ret_arr;
9598 }
9599
9600 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
9601         LDKu8slice ser_ref;
9602         ser_ref.datalen = *((uint32_t*)ser);
9603         ser_ref.data = (int8_t*)(ser + 4);
9604         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9605         *ret_conv = ChannelConfig_read(ser_ref);
9606         return (long)ret_conv;
9607 }
9608
9609 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
9610         LDKUserConfig this_obj_conv;
9611         this_obj_conv.inner = (void*)(this_obj & (~1));
9612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9613         UserConfig_free(this_obj_conv);
9614 }
9615
9616 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
9617         LDKUserConfig this_ptr_conv;
9618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9619         this_ptr_conv.is_owned = false;
9620         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
9621         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9622         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9623         long ret_ref = (long)ret_var.inner;
9624         if (ret_var.is_owned) {
9625                 ret_ref |= 1;
9626         }
9627         return ret_ref;
9628 }
9629
9630 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
9631         LDKUserConfig this_ptr_conv;
9632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9633         this_ptr_conv.is_owned = false;
9634         LDKChannelHandshakeConfig val_conv;
9635         val_conv.inner = (void*)(val & (~1));
9636         val_conv.is_owned = (val & 1) || (val == 0);
9637         val_conv = ChannelHandshakeConfig_clone(&val_conv);
9638         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
9639 }
9640
9641 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
9642         LDKUserConfig this_ptr_conv;
9643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9644         this_ptr_conv.is_owned = false;
9645         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
9646         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9647         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9648         long ret_ref = (long)ret_var.inner;
9649         if (ret_var.is_owned) {
9650                 ret_ref |= 1;
9651         }
9652         return ret_ref;
9653 }
9654
9655 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
9656         LDKUserConfig this_ptr_conv;
9657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9658         this_ptr_conv.is_owned = false;
9659         LDKChannelHandshakeLimits val_conv;
9660         val_conv.inner = (void*)(val & (~1));
9661         val_conv.is_owned = (val & 1) || (val == 0);
9662         val_conv = ChannelHandshakeLimits_clone(&val_conv);
9663         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
9664 }
9665
9666 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
9667         LDKUserConfig this_ptr_conv;
9668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9669         this_ptr_conv.is_owned = false;
9670         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
9671         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9672         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9673         long ret_ref = (long)ret_var.inner;
9674         if (ret_var.is_owned) {
9675                 ret_ref |= 1;
9676         }
9677         return ret_ref;
9678 }
9679
9680 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
9681         LDKUserConfig this_ptr_conv;
9682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9683         this_ptr_conv.is_owned = false;
9684         LDKChannelConfig val_conv;
9685         val_conv.inner = (void*)(val & (~1));
9686         val_conv.is_owned = (val & 1) || (val == 0);
9687         val_conv = ChannelConfig_clone(&val_conv);
9688         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
9689 }
9690
9691 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) {
9692         LDKChannelHandshakeConfig own_channel_config_arg_conv;
9693         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
9694         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
9695         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
9696         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
9697         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
9698         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
9699         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
9700         LDKChannelConfig channel_options_arg_conv;
9701         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
9702         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
9703         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
9704         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
9705         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9706         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9707         long ret_ref = (long)ret_var.inner;
9708         if (ret_var.is_owned) {
9709                 ret_ref |= 1;
9710         }
9711         return ret_ref;
9712 }
9713
9714 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
9715         LDKUserConfig orig_conv;
9716         orig_conv.inner = (void*)(orig & (~1));
9717         orig_conv.is_owned = false;
9718         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
9719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9721         long ret_ref = (long)ret_var.inner;
9722         if (ret_var.is_owned) {
9723                 ret_ref |= 1;
9724         }
9725         return ret_ref;
9726 }
9727
9728 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
9729         LDKUserConfig ret_var = UserConfig_default();
9730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9732         long ret_ref = (long)ret_var.inner;
9733         if (ret_var.is_owned) {
9734                 ret_ref |= 1;
9735         }
9736         return ret_ref;
9737 }
9738
9739 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
9740         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
9741         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
9742         return ret_conv;
9743 }
9744
9745 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
9746         if ((this_ptr & 1) != 0) return;
9747         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
9748         FREE((void*)this_ptr);
9749         Access_free(this_ptr_conv);
9750 }
9751
9752 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
9753         if ((this_ptr & 1) != 0) return;
9754         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
9755         FREE((void*)this_ptr);
9756         Listen_free(this_ptr_conv);
9757 }
9758
9759 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
9760         if ((this_ptr & 1) != 0) return;
9761         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
9762         FREE((void*)this_ptr);
9763         Watch_free(this_ptr_conv);
9764 }
9765
9766 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
9767         if ((this_ptr & 1) != 0) return;
9768         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
9769         FREE((void*)this_ptr);
9770         Filter_free(this_ptr_conv);
9771 }
9772
9773 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
9774         LDKWatchedOutput this_obj_conv;
9775         this_obj_conv.inner = (void*)(this_obj & (~1));
9776         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9777         WatchedOutput_free(this_obj_conv);
9778 }
9779
9780 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
9781         LDKWatchedOutput this_ptr_conv;
9782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9783         this_ptr_conv.is_owned = false;
9784         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9785         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
9786         return ret_arr;
9787 }
9788
9789 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
9790         LDKWatchedOutput this_ptr_conv;
9791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9792         this_ptr_conv.is_owned = false;
9793         LDKThirtyTwoBytes val_ref;
9794         CHECK(*((uint32_t*)val) == 32);
9795         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9796         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
9797 }
9798
9799 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
9800         LDKWatchedOutput this_ptr_conv;
9801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9802         this_ptr_conv.is_owned = false;
9803         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
9804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9806         long ret_ref = (long)ret_var.inner;
9807         if (ret_var.is_owned) {
9808                 ret_ref |= 1;
9809         }
9810         return ret_ref;
9811 }
9812
9813 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
9814         LDKWatchedOutput this_ptr_conv;
9815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9816         this_ptr_conv.is_owned = false;
9817         LDKOutPoint val_conv;
9818         val_conv.inner = (void*)(val & (~1));
9819         val_conv.is_owned = (val & 1) || (val == 0);
9820         val_conv = OutPoint_clone(&val_conv);
9821         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
9822 }
9823
9824 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
9825         LDKWatchedOutput this_ptr_conv;
9826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9827         this_ptr_conv.is_owned = false;
9828         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
9829         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9830         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9831         return ret_arr;
9832 }
9833
9834 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
9835         LDKWatchedOutput this_ptr_conv;
9836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9837         this_ptr_conv.is_owned = false;
9838         LDKCVec_u8Z val_ref;
9839         val_ref.datalen = *((uint32_t*)val);
9840         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
9841         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
9842         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
9843 }
9844
9845 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
9846         LDKThirtyTwoBytes block_hash_arg_ref;
9847         CHECK(*((uint32_t*)block_hash_arg) == 32);
9848         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
9849         LDKOutPoint outpoint_arg_conv;
9850         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
9851         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
9852         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
9853         LDKCVec_u8Z script_pubkey_arg_ref;
9854         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
9855         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
9856         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
9857         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
9858         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9859         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9860         long ret_ref = (long)ret_var.inner;
9861         if (ret_var.is_owned) {
9862                 ret_ref |= 1;
9863         }
9864         return ret_ref;
9865 }
9866
9867 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
9868         if ((this_ptr & 1) != 0) return;
9869         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
9870         FREE((void*)this_ptr);
9871         BroadcasterInterface_free(this_ptr_conv);
9872 }
9873
9874 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
9875         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
9876         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
9877         return ret_conv;
9878 }
9879
9880 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
9881         if ((this_ptr & 1) != 0) return;
9882         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
9883         FREE((void*)this_ptr);
9884         FeeEstimator_free(this_ptr_conv);
9885 }
9886
9887 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
9888         LDKChainMonitor this_obj_conv;
9889         this_obj_conv.inner = (void*)(this_obj & (~1));
9890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9891         ChainMonitor_free(this_obj_conv);
9892 }
9893
9894 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9895         LDKChainMonitor this_arg_conv;
9896         this_arg_conv.inner = (void*)(this_arg & (~1));
9897         this_arg_conv.is_owned = false;
9898         unsigned char header_arr[80];
9899         CHECK(*((uint32_t*)header) == 80);
9900         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9901         unsigned char (*header_ref)[80] = &header_arr;
9902         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9903         txdata_constr.datalen = *((uint32_t*)txdata);
9904         if (txdata_constr.datalen > 0)
9905                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9906         else
9907                 txdata_constr.data = NULL;
9908         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9909         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9910                 uint32_t txdata_conv_30 = txdata_vals[e];
9911                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9912                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
9913                 txdata_constr.data[e] = txdata_conv_30_conv;
9914         }
9915         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
9916 }
9917
9918 void  __attribute__((visibility("default"))) TS_ChainMonitor_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9919         LDKChainMonitor this_arg_conv;
9920         this_arg_conv.inner = (void*)(this_arg & (~1));
9921         this_arg_conv.is_owned = false;
9922         unsigned char header_arr[80];
9923         CHECK(*((uint32_t*)header) == 80);
9924         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9925         unsigned char (*header_ref)[80] = &header_arr;
9926         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9927         txdata_constr.datalen = *((uint32_t*)txdata);
9928         if (txdata_constr.datalen > 0)
9929                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9930         else
9931                 txdata_constr.data = NULL;
9932         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9933         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9934                 uint32_t txdata_conv_30 = txdata_vals[e];
9935                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9936                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
9937                 txdata_constr.data[e] = txdata_conv_30_conv;
9938         }
9939         ChainMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height);
9940 }
9941
9942 void  __attribute__((visibility("default"))) TS_ChainMonitor_update_best_block(uint32_t this_arg, int8_tArray header, int32_t height) {
9943         LDKChainMonitor this_arg_conv;
9944         this_arg_conv.inner = (void*)(this_arg & (~1));
9945         this_arg_conv.is_owned = false;
9946         unsigned char header_arr[80];
9947         CHECK(*((uint32_t*)header) == 80);
9948         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9949         unsigned char (*header_ref)[80] = &header_arr;
9950         ChainMonitor_update_best_block(&this_arg_conv, header_ref, height);
9951 }
9952
9953 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
9954         LDKChainMonitor this_arg_conv;
9955         this_arg_conv.inner = (void*)(this_arg & (~1));
9956         this_arg_conv.is_owned = false;
9957         unsigned char header_arr[80];
9958         CHECK(*((uint32_t*)header) == 80);
9959         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9960         unsigned char (*header_ref)[80] = &header_arr;
9961         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
9962 }
9963
9964 void  __attribute__((visibility("default"))) TS_ChainMonitor_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
9965         LDKChainMonitor this_arg_conv;
9966         this_arg_conv.inner = (void*)(this_arg & (~1));
9967         this_arg_conv.is_owned = false;
9968         unsigned char txid_arr[32];
9969         CHECK(*((uint32_t*)txid) == 32);
9970         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
9971         unsigned char (*txid_ref)[32] = &txid_arr;
9972         ChainMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref);
9973 }
9974
9975 ptrArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_relevant_txids(uint32_t this_arg) {
9976         LDKChainMonitor this_arg_conv;
9977         this_arg_conv.inner = (void*)(this_arg & (~1));
9978         this_arg_conv.is_owned = false;
9979         LDKCVec_TxidZ ret_var = ChainMonitor_get_relevant_txids(&this_arg_conv);
9980         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
9981         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
9982         for (size_t m = 0; m < ret_var.datalen; m++) {
9983                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9984                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
9985                 ret_arr_ptr[m] = ret_conv_12_arr;
9986         }
9987         FREE(ret_var.data);
9988         return ret_arr;
9989 }
9990
9991 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
9992         LDKFilter *chain_source_conv_ptr = NULL;
9993         if (chain_source != 0) {
9994                 LDKFilter chain_source_conv;
9995                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
9996                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9997                 *chain_source_conv_ptr = chain_source_conv;
9998         }
9999         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10000         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10001         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
10002         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
10003         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
10004         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10005         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10006         long ret_ref = (long)ret_var.inner;
10007         if (ret_var.is_owned) {
10008                 ret_ref |= 1;
10009         }
10010         return ret_ref;
10011 }
10012
10013 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
10014         LDKChainMonitor this_arg_conv;
10015         this_arg_conv.inner = (void*)(this_arg & (~1));
10016         this_arg_conv.is_owned = false;
10017         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
10018         *ret = ChainMonitor_as_Watch(&this_arg_conv);
10019         return (long)ret;
10020 }
10021
10022 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
10023         LDKChainMonitor this_arg_conv;
10024         this_arg_conv.inner = (void*)(this_arg & (~1));
10025         this_arg_conv.is_owned = false;
10026         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10027         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
10028         return (long)ret;
10029 }
10030
10031 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
10032         LDKChannelMonitorUpdate this_obj_conv;
10033         this_obj_conv.inner = (void*)(this_obj & (~1));
10034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10035         ChannelMonitorUpdate_free(this_obj_conv);
10036 }
10037
10038 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
10039         LDKChannelMonitorUpdate this_ptr_conv;
10040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10041         this_ptr_conv.is_owned = false;
10042         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
10043         return ret_val;
10044 }
10045
10046 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
10047         LDKChannelMonitorUpdate this_ptr_conv;
10048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10049         this_ptr_conv.is_owned = false;
10050         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
10051 }
10052
10053 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
10054         LDKChannelMonitorUpdate orig_conv;
10055         orig_conv.inner = (void*)(orig & (~1));
10056         orig_conv.is_owned = false;
10057         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
10058         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10059         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10060         long ret_ref = (long)ret_var.inner;
10061         if (ret_var.is_owned) {
10062                 ret_ref |= 1;
10063         }
10064         return ret_ref;
10065 }
10066
10067 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
10068         LDKChannelMonitorUpdate obj_conv;
10069         obj_conv.inner = (void*)(obj & (~1));
10070         obj_conv.is_owned = false;
10071         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
10072         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10073         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10074         CVec_u8Z_free(ret_var);
10075         return ret_arr;
10076 }
10077
10078 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
10079         LDKu8slice ser_ref;
10080         ser_ref.datalen = *((uint32_t*)ser);
10081         ser_ref.data = (int8_t*)(ser + 4);
10082         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10083         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
10084         return (long)ret_conv;
10085 }
10086
10087 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
10088         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
10089         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
10090         return ret_conv;
10091 }
10092
10093 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
10094         LDKMonitorUpdateError this_obj_conv;
10095         this_obj_conv.inner = (void*)(this_obj & (~1));
10096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10097         MonitorUpdateError_free(this_obj_conv);
10098 }
10099
10100 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
10101         LDKMonitorUpdateError orig_conv;
10102         orig_conv.inner = (void*)(orig & (~1));
10103         orig_conv.is_owned = false;
10104         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
10105         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10106         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10107         long ret_ref = (long)ret_var.inner;
10108         if (ret_var.is_owned) {
10109                 ret_ref |= 1;
10110         }
10111         return ret_ref;
10112 }
10113
10114 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
10115         if ((this_ptr & 1) != 0) return;
10116         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
10117         FREE((void*)this_ptr);
10118         MonitorEvent_free(this_ptr_conv);
10119 }
10120
10121 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
10122         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
10123         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10124         *ret_copy = MonitorEvent_clone(orig_conv);
10125         long ret_ref = (long)ret_copy;
10126         return ret_ref;
10127 }
10128
10129 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
10130         LDKHTLCUpdate this_obj_conv;
10131         this_obj_conv.inner = (void*)(this_obj & (~1));
10132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10133         HTLCUpdate_free(this_obj_conv);
10134 }
10135
10136 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
10137         LDKHTLCUpdate orig_conv;
10138         orig_conv.inner = (void*)(orig & (~1));
10139         orig_conv.is_owned = false;
10140         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
10141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10143         long ret_ref = (long)ret_var.inner;
10144         if (ret_var.is_owned) {
10145                 ret_ref |= 1;
10146         }
10147         return ret_ref;
10148 }
10149
10150 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
10151         LDKHTLCUpdate obj_conv;
10152         obj_conv.inner = (void*)(obj & (~1));
10153         obj_conv.is_owned = false;
10154         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
10155         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10156         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10157         CVec_u8Z_free(ret_var);
10158         return ret_arr;
10159 }
10160
10161 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
10162         LDKu8slice ser_ref;
10163         ser_ref.datalen = *((uint32_t*)ser);
10164         ser_ref.data = (int8_t*)(ser + 4);
10165         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10166         *ret_conv = HTLCUpdate_read(ser_ref);
10167         return (long)ret_conv;
10168 }
10169
10170 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
10171         LDKChannelMonitor this_obj_conv;
10172         this_obj_conv.inner = (void*)(this_obj & (~1));
10173         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10174         ChannelMonitor_free(this_obj_conv);
10175 }
10176
10177 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
10178         LDKChannelMonitor orig_conv;
10179         orig_conv.inner = (void*)(orig & (~1));
10180         orig_conv.is_owned = false;
10181         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
10182         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10183         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10184         long ret_ref = (long)ret_var.inner;
10185         if (ret_var.is_owned) {
10186                 ret_ref |= 1;
10187         }
10188         return ret_ref;
10189 }
10190
10191 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
10192         LDKChannelMonitor obj_conv;
10193         obj_conv.inner = (void*)(obj & (~1));
10194         obj_conv.is_owned = false;
10195         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
10196         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10197         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10198         CVec_u8Z_free(ret_var);
10199         return ret_arr;
10200 }
10201
10202 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) {
10203         LDKChannelMonitor this_arg_conv;
10204         this_arg_conv.inner = (void*)(this_arg & (~1));
10205         this_arg_conv.is_owned = false;
10206         LDKChannelMonitorUpdate updates_conv;
10207         updates_conv.inner = (void*)(updates & (~1));
10208         updates_conv.is_owned = false;
10209         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10210         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10211         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
10212         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10213         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
10214         return (long)ret_conv;
10215 }
10216
10217 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
10218         LDKChannelMonitor this_arg_conv;
10219         this_arg_conv.inner = (void*)(this_arg & (~1));
10220         this_arg_conv.is_owned = false;
10221         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
10222         return ret_val;
10223 }
10224
10225 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
10226         LDKChannelMonitor this_arg_conv;
10227         this_arg_conv.inner = (void*)(this_arg & (~1));
10228         this_arg_conv.is_owned = false;
10229         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10230         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
10231         return (long)ret_ref;
10232 }
10233
10234 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
10235         LDKChannelMonitor this_arg_conv;
10236         this_arg_conv.inner = (void*)(this_arg & (~1));
10237         this_arg_conv.is_owned = false;
10238         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
10239         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10240         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10241         for (size_t c = 0; c < ret_var.datalen; c++) {
10242                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10243                 *ret_conv_54_ref = ret_var.data[c];
10244                 ret_arr_ptr[c] = (long)ret_conv_54_ref;
10245         }
10246         FREE(ret_var.data);
10247         return ret_arr;
10248 }
10249
10250 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
10251         LDKChannelMonitor this_arg_conv;
10252         this_arg_conv.inner = (void*)(this_arg & (~1));
10253         this_arg_conv.is_owned = false;
10254         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
10255         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
10256 }
10257
10258 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
10259         LDKChannelMonitor this_arg_conv;
10260         this_arg_conv.inner = (void*)(this_arg & (~1));
10261         this_arg_conv.is_owned = false;
10262         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
10263         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10264         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10265         for (size_t o = 0; o < ret_var.datalen; o++) {
10266                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
10267                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
10268                 long ret_conv_14_ref = (long)ret_conv_14_copy;
10269                 ret_arr_ptr[o] = ret_conv_14_ref;
10270         }
10271         FREE(ret_var.data);
10272         return ret_arr;
10273 }
10274
10275 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
10276         LDKChannelMonitor this_arg_conv;
10277         this_arg_conv.inner = (void*)(this_arg & (~1));
10278         this_arg_conv.is_owned = false;
10279         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
10280         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10281         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10282         for (size_t h = 0; h < ret_var.datalen; h++) {
10283                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10284                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
10285                 long ret_conv_7_ref = (long)ret_conv_7_copy;
10286                 ret_arr_ptr[h] = ret_conv_7_ref;
10287         }
10288         FREE(ret_var.data);
10289         return ret_arr;
10290 }
10291
10292 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
10293         LDKChannelMonitor this_arg_conv;
10294         this_arg_conv.inner = (void*)(this_arg & (~1));
10295         this_arg_conv.is_owned = false;
10296         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
10297         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
10298         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
10299         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
10300         for (size_t m = 0; m < ret_var.datalen; m++) {
10301                 LDKTransaction ret_conv_12_var = ret_var.data[m];
10302                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10303                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
10304                 Transaction_free(ret_conv_12_var);
10305                 ret_arr_ptr[m] = ret_conv_12_arr;
10306         }
10307         FREE(ret_var.data);
10308         return ret_arr;
10309 }
10310
10311 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) {
10312         LDKChannelMonitor this_arg_conv;
10313         this_arg_conv.inner = (void*)(this_arg & (~1));
10314         this_arg_conv.is_owned = false;
10315         unsigned char header_arr[80];
10316         CHECK(*((uint32_t*)header) == 80);
10317         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10318         unsigned char (*header_ref)[80] = &header_arr;
10319         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10320         txdata_constr.datalen = *((uint32_t*)txdata);
10321         if (txdata_constr.datalen > 0)
10322                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10323         else
10324                 txdata_constr.data = NULL;
10325         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
10326         for (size_t e = 0; e < txdata_constr.datalen; e++) {
10327                 uint32_t txdata_conv_30 = txdata_vals[e];
10328                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
10329                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
10330                 txdata_constr.data[e] = txdata_conv_30_conv;
10331         }
10332         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10333         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10334         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10335         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);
10336         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10337         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10338         for (size_t x = 0; x < ret_var.datalen; x++) {
10339                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10340                 *ret_conv_49_ref = ret_var.data[x];
10341                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
10342         }
10343         FREE(ret_var.data);
10344         return ret_arr;
10345 }
10346
10347 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) {
10348         LDKChannelMonitor this_arg_conv;
10349         this_arg_conv.inner = (void*)(this_arg & (~1));
10350         this_arg_conv.is_owned = false;
10351         unsigned char header_arr[80];
10352         CHECK(*((uint32_t*)header) == 80);
10353         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10354         unsigned char (*header_ref)[80] = &header_arr;
10355         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10356         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10357         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10358         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10359 }
10360
10361 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
10362         LDKChannelMonitor this_arg_conv;
10363         this_arg_conv.inner = (void*)(this_arg & (~1));
10364         this_arg_conv.is_owned = false;
10365         unsigned char header_arr[80];
10366         CHECK(*((uint32_t*)header) == 80);
10367         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10368         unsigned char (*header_ref)[80] = &header_arr;
10369         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10370         txdata_constr.datalen = *((uint32_t*)txdata);
10371         if (txdata_constr.datalen > 0)
10372                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10373         else
10374                 txdata_constr.data = NULL;
10375         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
10376         for (size_t e = 0; e < txdata_constr.datalen; e++) {
10377                 uint32_t txdata_conv_30 = txdata_vals[e];
10378                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
10379                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
10380                 txdata_constr.data[e] = txdata_conv_30_conv;
10381         }
10382         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10383         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10384         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10385         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10386         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10387         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10388         for (size_t x = 0; x < ret_var.datalen; x++) {
10389                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10390                 *ret_conv_49_ref = ret_var.data[x];
10391                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
10392         }
10393         FREE(ret_var.data);
10394         return ret_arr;
10395 }
10396
10397 void  __attribute__((visibility("default"))) TS_ChannelMonitor_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
10398         LDKChannelMonitor this_arg_conv;
10399         this_arg_conv.inner = (void*)(this_arg & (~1));
10400         this_arg_conv.is_owned = false;
10401         unsigned char txid_arr[32];
10402         CHECK(*((uint32_t*)txid) == 32);
10403         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
10404         unsigned char (*txid_ref)[32] = &txid_arr;
10405         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10406         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10407         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10408         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
10409 }
10410
10411 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_update_best_block(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
10412         LDKChannelMonitor this_arg_conv;
10413         this_arg_conv.inner = (void*)(this_arg & (~1));
10414         this_arg_conv.is_owned = false;
10415         unsigned char header_arr[80];
10416         CHECK(*((uint32_t*)header) == 80);
10417         memcpy(header_arr, (uint8_t*)(header + 4), 80);
10418         unsigned char (*header_ref)[80] = &header_arr;
10419         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
10420         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
10421         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10422         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_update_best_block(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
10423         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10424         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10425         for (size_t x = 0; x < ret_var.datalen; x++) {
10426                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10427                 *ret_conv_49_ref = ret_var.data[x];
10428                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
10429         }
10430         FREE(ret_var.data);
10431         return ret_arr;
10432 }
10433
10434 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
10435         LDKChannelMonitor this_arg_conv;
10436         this_arg_conv.inner = (void*)(this_arg & (~1));
10437         this_arg_conv.is_owned = false;
10438         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
10439         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
10440         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
10441         for (size_t m = 0; m < ret_var.datalen; m++) {
10442                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10443                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
10444                 ret_arr_ptr[m] = ret_conv_12_arr;
10445         }
10446         FREE(ret_var.data);
10447         return ret_arr;
10448 }
10449
10450 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
10451         if ((this_ptr & 1) != 0) return;
10452         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
10453         FREE((void*)this_ptr);
10454         Persist_free(this_ptr_conv);
10455 }
10456
10457 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
10458         LDKu8slice ser_ref;
10459         ser_ref.datalen = *((uint32_t*)ser);
10460         ser_ref.data = (int8_t*)(ser + 4);
10461         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
10462         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10463         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
10464         return (long)ret_conv;
10465 }
10466
10467 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
10468         LDKOutPoint this_obj_conv;
10469         this_obj_conv.inner = (void*)(this_obj & (~1));
10470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10471         OutPoint_free(this_obj_conv);
10472 }
10473
10474 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
10475         LDKOutPoint this_ptr_conv;
10476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10477         this_ptr_conv.is_owned = false;
10478         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10479         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
10480         return ret_arr;
10481 }
10482
10483 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
10484         LDKOutPoint this_ptr_conv;
10485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10486         this_ptr_conv.is_owned = false;
10487         LDKThirtyTwoBytes val_ref;
10488         CHECK(*((uint32_t*)val) == 32);
10489         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10490         OutPoint_set_txid(&this_ptr_conv, val_ref);
10491 }
10492
10493 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
10494         LDKOutPoint this_ptr_conv;
10495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10496         this_ptr_conv.is_owned = false;
10497         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
10498         return ret_val;
10499 }
10500
10501 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
10502         LDKOutPoint this_ptr_conv;
10503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10504         this_ptr_conv.is_owned = false;
10505         OutPoint_set_index(&this_ptr_conv, val);
10506 }
10507
10508 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
10509         LDKThirtyTwoBytes txid_arg_ref;
10510         CHECK(*((uint32_t*)txid_arg) == 32);
10511         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
10512         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
10513         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10514         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10515         long ret_ref = (long)ret_var.inner;
10516         if (ret_var.is_owned) {
10517                 ret_ref |= 1;
10518         }
10519         return ret_ref;
10520 }
10521
10522 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
10523         LDKOutPoint orig_conv;
10524         orig_conv.inner = (void*)(orig & (~1));
10525         orig_conv.is_owned = false;
10526         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
10527         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10528         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10529         long ret_ref = (long)ret_var.inner;
10530         if (ret_var.is_owned) {
10531                 ret_ref |= 1;
10532         }
10533         return ret_ref;
10534 }
10535
10536 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
10537         LDKOutPoint this_arg_conv;
10538         this_arg_conv.inner = (void*)(this_arg & (~1));
10539         this_arg_conv.is_owned = false;
10540         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10541         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
10542         return ret_arr;
10543 }
10544
10545 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
10546         LDKOutPoint obj_conv;
10547         obj_conv.inner = (void*)(obj & (~1));
10548         obj_conv.is_owned = false;
10549         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
10550         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10551         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10552         CVec_u8Z_free(ret_var);
10553         return ret_arr;
10554 }
10555
10556 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
10557         LDKu8slice ser_ref;
10558         ser_ref.datalen = *((uint32_t*)ser);
10559         ser_ref.data = (int8_t*)(ser + 4);
10560         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10561         *ret_conv = OutPoint_read(ser_ref);
10562         return (long)ret_conv;
10563 }
10564
10565 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
10566         LDKDelayedPaymentOutputDescriptor this_obj_conv;
10567         this_obj_conv.inner = (void*)(this_obj & (~1));
10568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10569         DelayedPaymentOutputDescriptor_free(this_obj_conv);
10570 }
10571
10572 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10573         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10575         this_ptr_conv.is_owned = false;
10576         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10577         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10578         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10579         long ret_ref = (long)ret_var.inner;
10580         if (ret_var.is_owned) {
10581                 ret_ref |= 1;
10582         }
10583         return ret_ref;
10584 }
10585
10586 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10587         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10589         this_ptr_conv.is_owned = false;
10590         LDKOutPoint val_conv;
10591         val_conv.inner = (void*)(val & (~1));
10592         val_conv.is_owned = (val & 1) || (val == 0);
10593         val_conv = OutPoint_clone(&val_conv);
10594         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10595 }
10596
10597 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
10598         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10600         this_ptr_conv.is_owned = false;
10601         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10602         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10603         return ret_arr;
10604 }
10605
10606 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10607         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10609         this_ptr_conv.is_owned = false;
10610         LDKPublicKey val_ref;
10611         CHECK(*((uint32_t*)val) == 33);
10612         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10613         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
10614 }
10615
10616 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
10617         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10619         this_ptr_conv.is_owned = false;
10620         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
10621         return ret_val;
10622 }
10623
10624 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
10625         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10627         this_ptr_conv.is_owned = false;
10628         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
10629 }
10630
10631 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10632         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10634         this_ptr_conv.is_owned = false;
10635         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10636         FREE((void*)val);
10637         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10638 }
10639
10640 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
10641         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10643         this_ptr_conv.is_owned = false;
10644         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10645         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
10646         return ret_arr;
10647 }
10648
10649 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
10650         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10652         this_ptr_conv.is_owned = false;
10653         LDKPublicKey val_ref;
10654         CHECK(*((uint32_t*)val) == 33);
10655         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10656         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
10657 }
10658
10659 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10660         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10662         this_ptr_conv.is_owned = false;
10663         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10664         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10665         return ret_arr;
10666 }
10667
10668 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10669         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10671         this_ptr_conv.is_owned = false;
10672         LDKThirtyTwoBytes val_ref;
10673         CHECK(*((uint32_t*)val) == 32);
10674         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10675         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10676 }
10677
10678 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10679         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10681         this_ptr_conv.is_owned = false;
10682         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10683         return ret_val;
10684 }
10685
10686 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10687         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10689         this_ptr_conv.is_owned = false;
10690         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10691 }
10692
10693 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) {
10694         LDKOutPoint outpoint_arg_conv;
10695         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10696         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10697         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10698         LDKPublicKey per_commitment_point_arg_ref;
10699         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
10700         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
10701         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10702         FREE((void*)output_arg);
10703         LDKPublicKey revocation_pubkey_arg_ref;
10704         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
10705         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
10706         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10707         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10708         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10709         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);
10710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10712         long ret_ref = (long)ret_var.inner;
10713         if (ret_var.is_owned) {
10714                 ret_ref |= 1;
10715         }
10716         return ret_ref;
10717 }
10718
10719 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
10720         LDKDelayedPaymentOutputDescriptor orig_conv;
10721         orig_conv.inner = (void*)(orig & (~1));
10722         orig_conv.is_owned = false;
10723         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
10724         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10725         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10726         long ret_ref = (long)ret_var.inner;
10727         if (ret_var.is_owned) {
10728                 ret_ref |= 1;
10729         }
10730         return ret_ref;
10731 }
10732
10733 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
10734         LDKStaticPaymentOutputDescriptor this_obj_conv;
10735         this_obj_conv.inner = (void*)(this_obj & (~1));
10736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10737         StaticPaymentOutputDescriptor_free(this_obj_conv);
10738 }
10739
10740 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10741         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10743         this_ptr_conv.is_owned = false;
10744         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10745         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10746         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10747         long ret_ref = (long)ret_var.inner;
10748         if (ret_var.is_owned) {
10749                 ret_ref |= 1;
10750         }
10751         return ret_ref;
10752 }
10753
10754 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10755         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10757         this_ptr_conv.is_owned = false;
10758         LDKOutPoint val_conv;
10759         val_conv.inner = (void*)(val & (~1));
10760         val_conv.is_owned = (val & 1) || (val == 0);
10761         val_conv = OutPoint_clone(&val_conv);
10762         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10763 }
10764
10765 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10766         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10768         this_ptr_conv.is_owned = false;
10769         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10770         FREE((void*)val);
10771         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10772 }
10773
10774 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10775         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10777         this_ptr_conv.is_owned = false;
10778         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10779         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10780         return ret_arr;
10781 }
10782
10783 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10784         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10786         this_ptr_conv.is_owned = false;
10787         LDKThirtyTwoBytes val_ref;
10788         CHECK(*((uint32_t*)val) == 32);
10789         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10790         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10791 }
10792
10793 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10794         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10796         this_ptr_conv.is_owned = false;
10797         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10798         return ret_val;
10799 }
10800
10801 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10802         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10804         this_ptr_conv.is_owned = false;
10805         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10806 }
10807
10808 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) {
10809         LDKOutPoint outpoint_arg_conv;
10810         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10811         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10812         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10813         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10814         FREE((void*)output_arg);
10815         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10816         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10817         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10818         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
10819         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10820         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10821         long ret_ref = (long)ret_var.inner;
10822         if (ret_var.is_owned) {
10823                 ret_ref |= 1;
10824         }
10825         return ret_ref;
10826 }
10827
10828 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
10829         LDKStaticPaymentOutputDescriptor orig_conv;
10830         orig_conv.inner = (void*)(orig & (~1));
10831         orig_conv.is_owned = false;
10832         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
10833         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10834         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10835         long ret_ref = (long)ret_var.inner;
10836         if (ret_var.is_owned) {
10837                 ret_ref |= 1;
10838         }
10839         return ret_ref;
10840 }
10841
10842 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
10843         if ((this_ptr & 1) != 0) return;
10844         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
10845         FREE((void*)this_ptr);
10846         SpendableOutputDescriptor_free(this_ptr_conv);
10847 }
10848
10849 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
10850         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
10851         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
10852         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
10853         long ret_ref = (long)ret_copy;
10854         return ret_ref;
10855 }
10856
10857 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
10858         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
10859         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
10860         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10861         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10862         CVec_u8Z_free(ret_var);
10863         return ret_arr;
10864 }
10865
10866 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
10867         LDKu8slice ser_ref;
10868         ser_ref.datalen = *((uint32_t*)ser);
10869         ser_ref.data = (int8_t*)(ser + 4);
10870         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10871         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
10872         return (long)ret_conv;
10873 }
10874
10875 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
10876         if ((this_ptr & 1) != 0) return;
10877         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
10878         FREE((void*)this_ptr);
10879         BaseSign_free(this_ptr_conv);
10880 }
10881
10882 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
10883         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
10884         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10885         *ret = Sign_clone(orig_conv);
10886         return (long)ret;
10887 }
10888
10889 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
10890         if ((this_ptr & 1) != 0) return;
10891         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
10892         FREE((void*)this_ptr);
10893         Sign_free(this_ptr_conv);
10894 }
10895
10896 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
10897         if ((this_ptr & 1) != 0) return;
10898         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
10899         FREE((void*)this_ptr);
10900         KeysInterface_free(this_ptr_conv);
10901 }
10902
10903 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
10904         LDKInMemorySigner this_obj_conv;
10905         this_obj_conv.inner = (void*)(this_obj & (~1));
10906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10907         InMemorySigner_free(this_obj_conv);
10908 }
10909
10910 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
10911         LDKInMemorySigner this_ptr_conv;
10912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10913         this_ptr_conv.is_owned = false;
10914         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10915         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
10916         return ret_arr;
10917 }
10918
10919 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
10920         LDKInMemorySigner this_ptr_conv;
10921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10922         this_ptr_conv.is_owned = false;
10923         LDKSecretKey val_ref;
10924         CHECK(*((uint32_t*)val) == 32);
10925         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10926         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
10927 }
10928
10929 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
10930         LDKInMemorySigner this_ptr_conv;
10931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10932         this_ptr_conv.is_owned = false;
10933         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10934         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
10935         return ret_arr;
10936 }
10937
10938 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
10939         LDKInMemorySigner this_ptr_conv;
10940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10941         this_ptr_conv.is_owned = false;
10942         LDKSecretKey val_ref;
10943         CHECK(*((uint32_t*)val) == 32);
10944         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10945         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
10946 }
10947
10948 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
10949         LDKInMemorySigner this_ptr_conv;
10950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10951         this_ptr_conv.is_owned = false;
10952         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10953         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
10954         return ret_arr;
10955 }
10956
10957 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
10958         LDKInMemorySigner this_ptr_conv;
10959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10960         this_ptr_conv.is_owned = false;
10961         LDKSecretKey val_ref;
10962         CHECK(*((uint32_t*)val) == 32);
10963         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10964         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
10965 }
10966
10967 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
10968         LDKInMemorySigner this_ptr_conv;
10969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10970         this_ptr_conv.is_owned = false;
10971         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10972         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
10973         return ret_arr;
10974 }
10975
10976 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
10977         LDKInMemorySigner this_ptr_conv;
10978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10979         this_ptr_conv.is_owned = false;
10980         LDKSecretKey val_ref;
10981         CHECK(*((uint32_t*)val) == 32);
10982         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10983         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
10984 }
10985
10986 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
10987         LDKInMemorySigner this_ptr_conv;
10988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10989         this_ptr_conv.is_owned = false;
10990         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10991         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
10992         return ret_arr;
10993 }
10994
10995 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
10996         LDKInMemorySigner this_ptr_conv;
10997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10998         this_ptr_conv.is_owned = false;
10999         LDKSecretKey val_ref;
11000         CHECK(*((uint32_t*)val) == 32);
11001         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
11002         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
11003 }
11004
11005 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
11006         LDKInMemorySigner this_ptr_conv;
11007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11008         this_ptr_conv.is_owned = false;
11009         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11010         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
11011         return ret_arr;
11012 }
11013
11014 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
11015         LDKInMemorySigner this_ptr_conv;
11016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11017         this_ptr_conv.is_owned = false;
11018         LDKThirtyTwoBytes val_ref;
11019         CHECK(*((uint32_t*)val) == 32);
11020         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11021         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
11022 }
11023
11024 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
11025         LDKInMemorySigner orig_conv;
11026         orig_conv.inner = (void*)(orig & (~1));
11027         orig_conv.is_owned = false;
11028         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
11029         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11030         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11031         long ret_ref = (long)ret_var.inner;
11032         if (ret_var.is_owned) {
11033                 ret_ref |= 1;
11034         }
11035         return ret_ref;
11036 }
11037
11038 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) {
11039         LDKSecretKey funding_key_ref;
11040         CHECK(*((uint32_t*)funding_key) == 32);
11041         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
11042         LDKSecretKey revocation_base_key_ref;
11043         CHECK(*((uint32_t*)revocation_base_key) == 32);
11044         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
11045         LDKSecretKey payment_key_ref;
11046         CHECK(*((uint32_t*)payment_key) == 32);
11047         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
11048         LDKSecretKey delayed_payment_base_key_ref;
11049         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
11050         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
11051         LDKSecretKey htlc_base_key_ref;
11052         CHECK(*((uint32_t*)htlc_base_key) == 32);
11053         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
11054         LDKThirtyTwoBytes commitment_seed_ref;
11055         CHECK(*((uint32_t*)commitment_seed) == 32);
11056         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
11057         LDKThirtyTwoBytes channel_keys_id_ref;
11058         CHECK(*((uint32_t*)channel_keys_id) == 32);
11059         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
11060         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);
11061         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11062         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11063         long ret_ref = (long)ret_var.inner;
11064         if (ret_var.is_owned) {
11065                 ret_ref |= 1;
11066         }
11067         return ret_ref;
11068 }
11069
11070 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
11071         LDKInMemorySigner this_arg_conv;
11072         this_arg_conv.inner = (void*)(this_arg & (~1));
11073         this_arg_conv.is_owned = false;
11074         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
11075         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11076         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11077         long ret_ref = (long)ret_var.inner;
11078         if (ret_var.is_owned) {
11079                 ret_ref |= 1;
11080         }
11081         return ret_ref;
11082 }
11083
11084 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
11085         LDKInMemorySigner this_arg_conv;
11086         this_arg_conv.inner = (void*)(this_arg & (~1));
11087         this_arg_conv.is_owned = false;
11088         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
11089         return ret_val;
11090 }
11091
11092 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
11093         LDKInMemorySigner this_arg_conv;
11094         this_arg_conv.inner = (void*)(this_arg & (~1));
11095         this_arg_conv.is_owned = false;
11096         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
11097         return ret_val;
11098 }
11099
11100 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
11101         LDKInMemorySigner this_arg_conv;
11102         this_arg_conv.inner = (void*)(this_arg & (~1));
11103         this_arg_conv.is_owned = false;
11104         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
11105         return ret_val;
11106 }
11107
11108 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
11109         LDKInMemorySigner this_arg_conv;
11110         this_arg_conv.inner = (void*)(this_arg & (~1));
11111         this_arg_conv.is_owned = false;
11112         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
11113         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11114         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11115         long ret_ref = (long)ret_var.inner;
11116         if (ret_var.is_owned) {
11117                 ret_ref |= 1;
11118         }
11119         return ret_ref;
11120 }
11121
11122 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
11123         LDKInMemorySigner this_arg_conv;
11124         this_arg_conv.inner = (void*)(this_arg & (~1));
11125         this_arg_conv.is_owned = false;
11126         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
11127         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11128         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11129         long ret_ref = (long)ret_var.inner;
11130         if (ret_var.is_owned) {
11131                 ret_ref |= 1;
11132         }
11133         return ret_ref;
11134 }
11135
11136 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) {
11137         LDKInMemorySigner this_arg_conv;
11138         this_arg_conv.inner = (void*)(this_arg & (~1));
11139         this_arg_conv.is_owned = false;
11140         LDKTransaction spend_tx_ref;
11141         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
11142         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11143         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
11144         spend_tx_ref.data_is_owned = true;
11145         LDKStaticPaymentOutputDescriptor descriptor_conv;
11146         descriptor_conv.inner = (void*)(descriptor & (~1));
11147         descriptor_conv.is_owned = false;
11148         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11149         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11150         return (long)ret_conv;
11151 }
11152
11153 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) {
11154         LDKInMemorySigner this_arg_conv;
11155         this_arg_conv.inner = (void*)(this_arg & (~1));
11156         this_arg_conv.is_owned = false;
11157         LDKTransaction spend_tx_ref;
11158         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
11159         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
11160         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
11161         spend_tx_ref.data_is_owned = true;
11162         LDKDelayedPaymentOutputDescriptor descriptor_conv;
11163         descriptor_conv.inner = (void*)(descriptor & (~1));
11164         descriptor_conv.is_owned = false;
11165         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11166         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
11167         return (long)ret_conv;
11168 }
11169
11170 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
11171         LDKInMemorySigner this_arg_conv;
11172         this_arg_conv.inner = (void*)(this_arg & (~1));
11173         this_arg_conv.is_owned = false;
11174         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
11175         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
11176         return (long)ret;
11177 }
11178
11179 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
11180         LDKInMemorySigner this_arg_conv;
11181         this_arg_conv.inner = (void*)(this_arg & (~1));
11182         this_arg_conv.is_owned = false;
11183         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
11184         *ret = InMemorySigner_as_Sign(&this_arg_conv);
11185         return (long)ret;
11186 }
11187
11188 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
11189         LDKInMemorySigner obj_conv;
11190         obj_conv.inner = (void*)(obj & (~1));
11191         obj_conv.is_owned = false;
11192         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
11193         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11194         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11195         CVec_u8Z_free(ret_var);
11196         return ret_arr;
11197 }
11198
11199 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
11200         LDKu8slice ser_ref;
11201         ser_ref.datalen = *((uint32_t*)ser);
11202         ser_ref.data = (int8_t*)(ser + 4);
11203         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11204         *ret_conv = InMemorySigner_read(ser_ref);
11205         return (long)ret_conv;
11206 }
11207
11208 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
11209         LDKKeysManager this_obj_conv;
11210         this_obj_conv.inner = (void*)(this_obj & (~1));
11211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11212         KeysManager_free(this_obj_conv);
11213 }
11214
11215 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
11216         unsigned char seed_arr[32];
11217         CHECK(*((uint32_t*)seed) == 32);
11218         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
11219         unsigned char (*seed_ref)[32] = &seed_arr;
11220         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
11221         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11222         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11223         long ret_ref = (long)ret_var.inner;
11224         if (ret_var.is_owned) {
11225                 ret_ref |= 1;
11226         }
11227         return ret_ref;
11228 }
11229
11230 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
11231         LDKKeysManager this_arg_conv;
11232         this_arg_conv.inner = (void*)(this_arg & (~1));
11233         this_arg_conv.is_owned = false;
11234         unsigned char params_arr[32];
11235         CHECK(*((uint32_t*)params) == 32);
11236         memcpy(params_arr, (uint8_t*)(params + 4), 32);
11237         unsigned char (*params_ref)[32] = &params_arr;
11238         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
11239         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11240         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11241         long ret_ref = (long)ret_var.inner;
11242         if (ret_var.is_owned) {
11243                 ret_ref |= 1;
11244         }
11245         return ret_ref;
11246 }
11247
11248 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) {
11249         LDKKeysManager this_arg_conv;
11250         this_arg_conv.inner = (void*)(this_arg & (~1));
11251         this_arg_conv.is_owned = false;
11252         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
11253         descriptors_constr.datalen = *((uint32_t*)descriptors);
11254         if (descriptors_constr.datalen > 0)
11255                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
11256         else
11257                 descriptors_constr.data = NULL;
11258         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
11259         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
11260                 uint32_t descriptors_conv_27 = descriptors_vals[b];
11261                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
11262                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
11263                 descriptors_constr.data[b] = descriptors_conv_27_conv;
11264         }
11265         LDKCVec_TxOutZ outputs_constr;
11266         outputs_constr.datalen = *((uint32_t*)outputs);
11267         if (outputs_constr.datalen > 0)
11268                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11269         else
11270                 outputs_constr.data = NULL;
11271         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
11272         for (size_t h = 0; h < outputs_constr.datalen; h++) {
11273                 uint32_t outputs_conv_7 = outputs_vals[h];
11274                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
11275                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
11276                 outputs_constr.data[h] = outputs_conv_7_conv;
11277         }
11278         LDKCVec_u8Z change_destination_script_ref;
11279         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
11280         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
11281         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
11282         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11283         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
11284         return (long)ret_conv;
11285 }
11286
11287 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
11288         LDKKeysManager this_arg_conv;
11289         this_arg_conv.inner = (void*)(this_arg & (~1));
11290         this_arg_conv.is_owned = false;
11291         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
11292         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
11293         return (long)ret;
11294 }
11295
11296 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
11297         LDKChannelManager this_obj_conv;
11298         this_obj_conv.inner = (void*)(this_obj & (~1));
11299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11300         ChannelManager_free(this_obj_conv);
11301 }
11302
11303 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
11304         LDKChainParameters this_obj_conv;
11305         this_obj_conv.inner = (void*)(this_obj & (~1));
11306         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11307         ChainParameters_free(this_obj_conv);
11308 }
11309
11310 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
11311         LDKChainParameters this_ptr_conv;
11312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11313         this_ptr_conv.is_owned = false;
11314         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
11315         return ret_conv;
11316 }
11317
11318 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
11319         LDKChainParameters this_ptr_conv;
11320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11321         this_ptr_conv.is_owned = false;
11322         LDKNetwork val_conv = LDKNetwork_from_js(val);
11323         ChainParameters_set_network(&this_ptr_conv, val_conv);
11324 }
11325
11326 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
11327         LDKChainParameters this_ptr_conv;
11328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11329         this_ptr_conv.is_owned = false;
11330         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
11331         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11332         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11333         long ret_ref = (long)ret_var.inner;
11334         if (ret_var.is_owned) {
11335                 ret_ref |= 1;
11336         }
11337         return ret_ref;
11338 }
11339
11340 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
11341         LDKChainParameters this_ptr_conv;
11342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11343         this_ptr_conv.is_owned = false;
11344         LDKBestBlock val_conv;
11345         val_conv.inner = (void*)(val & (~1));
11346         val_conv.is_owned = (val & 1) || (val == 0);
11347         val_conv = BestBlock_clone(&val_conv);
11348         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
11349 }
11350
11351 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
11352         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
11353         LDKBestBlock best_block_arg_conv;
11354         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
11355         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
11356         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
11357         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
11358         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11359         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11360         long ret_ref = (long)ret_var.inner;
11361         if (ret_var.is_owned) {
11362                 ret_ref |= 1;
11363         }
11364         return ret_ref;
11365 }
11366
11367 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
11368         LDKBestBlock this_obj_conv;
11369         this_obj_conv.inner = (void*)(this_obj & (~1));
11370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11371         BestBlock_free(this_obj_conv);
11372 }
11373
11374 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
11375         LDKBestBlock orig_conv;
11376         orig_conv.inner = (void*)(orig & (~1));
11377         orig_conv.is_owned = false;
11378         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
11379         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11380         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11381         long ret_ref = (long)ret_var.inner;
11382         if (ret_var.is_owned) {
11383                 ret_ref |= 1;
11384         }
11385         return ret_ref;
11386 }
11387
11388 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
11389         LDKNetwork network_conv = LDKNetwork_from_js(network);
11390         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
11391         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11392         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11393         long ret_ref = (long)ret_var.inner;
11394         if (ret_var.is_owned) {
11395                 ret_ref |= 1;
11396         }
11397         return ret_ref;
11398 }
11399
11400 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
11401         LDKThirtyTwoBytes block_hash_ref;
11402         CHECK(*((uint32_t*)block_hash) == 32);
11403         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
11404         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
11405         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11406         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11407         long ret_ref = (long)ret_var.inner;
11408         if (ret_var.is_owned) {
11409                 ret_ref |= 1;
11410         }
11411         return ret_ref;
11412 }
11413
11414 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
11415         LDKBestBlock 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(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11419         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
11420         return ret_arr;
11421 }
11422
11423 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
11424         LDKBestBlock this_arg_conv;
11425         this_arg_conv.inner = (void*)(this_arg & (~1));
11426         this_arg_conv.is_owned = false;
11427         int32_t ret_val = BestBlock_height(&this_arg_conv);
11428         return ret_val;
11429 }
11430
11431 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
11432         LDKChannelDetails this_obj_conv;
11433         this_obj_conv.inner = (void*)(this_obj & (~1));
11434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11435         ChannelDetails_free(this_obj_conv);
11436 }
11437
11438 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
11439         LDKChannelDetails this_ptr_conv;
11440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11441         this_ptr_conv.is_owned = false;
11442         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11443         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
11444         return ret_arr;
11445 }
11446
11447 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
11448         LDKChannelDetails this_ptr_conv;
11449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11450         this_ptr_conv.is_owned = false;
11451         LDKThirtyTwoBytes val_ref;
11452         CHECK(*((uint32_t*)val) == 32);
11453         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11454         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
11455 }
11456
11457 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
11458         LDKChannelDetails this_ptr_conv;
11459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11460         this_ptr_conv.is_owned = false;
11461         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11462         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
11463         long ret_ref = (long)ret_copy;
11464         return ret_ref;
11465 }
11466
11467 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
11468         LDKChannelDetails this_ptr_conv;
11469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11470         this_ptr_conv.is_owned = false;
11471         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
11472         FREE((void*)val);
11473         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
11474 }
11475
11476 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
11477         LDKChannelDetails this_ptr_conv;
11478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11479         this_ptr_conv.is_owned = false;
11480         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11481         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
11482         return ret_arr;
11483 }
11484
11485 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
11486         LDKChannelDetails this_ptr_conv;
11487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11488         this_ptr_conv.is_owned = false;
11489         LDKPublicKey val_ref;
11490         CHECK(*((uint32_t*)val) == 33);
11491         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11492         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
11493 }
11494
11495 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
11496         LDKChannelDetails this_ptr_conv;
11497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11498         this_ptr_conv.is_owned = false;
11499         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
11500         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11501         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11502         long ret_ref = (long)ret_var.inner;
11503         if (ret_var.is_owned) {
11504                 ret_ref |= 1;
11505         }
11506         return ret_ref;
11507 }
11508
11509 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
11510         LDKChannelDetails this_ptr_conv;
11511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11512         this_ptr_conv.is_owned = false;
11513         LDKInitFeatures val_conv;
11514         val_conv.inner = (void*)(val & (~1));
11515         val_conv.is_owned = (val & 1) || (val == 0);
11516         val_conv = InitFeatures_clone(&val_conv);
11517         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
11518 }
11519
11520 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
11521         LDKChannelDetails this_ptr_conv;
11522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11523         this_ptr_conv.is_owned = false;
11524         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
11525         return ret_val;
11526 }
11527
11528 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
11529         LDKChannelDetails this_ptr_conv;
11530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11531         this_ptr_conv.is_owned = false;
11532         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
11533 }
11534
11535 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
11536         LDKChannelDetails this_ptr_conv;
11537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11538         this_ptr_conv.is_owned = false;
11539         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
11540         return ret_val;
11541 }
11542
11543 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
11544         LDKChannelDetails this_ptr_conv;
11545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11546         this_ptr_conv.is_owned = false;
11547         ChannelDetails_set_user_id(&this_ptr_conv, val);
11548 }
11549
11550 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
11551         LDKChannelDetails this_ptr_conv;
11552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11553         this_ptr_conv.is_owned = false;
11554         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
11555         return ret_val;
11556 }
11557
11558 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
11559         LDKChannelDetails this_ptr_conv;
11560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11561         this_ptr_conv.is_owned = false;
11562         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
11563 }
11564
11565 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
11566         LDKChannelDetails this_ptr_conv;
11567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11568         this_ptr_conv.is_owned = false;
11569         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
11570         return ret_val;
11571 }
11572
11573 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
11574         LDKChannelDetails this_ptr_conv;
11575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11576         this_ptr_conv.is_owned = false;
11577         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
11578 }
11579
11580 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
11581         LDKChannelDetails this_ptr_conv;
11582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11583         this_ptr_conv.is_owned = false;
11584         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
11585         return ret_val;
11586 }
11587
11588 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
11589         LDKChannelDetails this_ptr_conv;
11590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11591         this_ptr_conv.is_owned = false;
11592         ChannelDetails_set_is_live(&this_ptr_conv, val);
11593 }
11594
11595 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
11596         LDKChannelDetails orig_conv;
11597         orig_conv.inner = (void*)(orig & (~1));
11598         orig_conv.is_owned = false;
11599         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
11600         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11601         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11602         long ret_ref = (long)ret_var.inner;
11603         if (ret_var.is_owned) {
11604                 ret_ref |= 1;
11605         }
11606         return ret_ref;
11607 }
11608
11609 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
11610         if ((this_ptr & 1) != 0) return;
11611         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
11612         FREE((void*)this_ptr);
11613         PaymentSendFailure_free(this_ptr_conv);
11614 }
11615
11616 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
11617         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
11618         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
11619         *ret_copy = PaymentSendFailure_clone(orig_conv);
11620         long ret_ref = (long)ret_copy;
11621         return ret_ref;
11622 }
11623
11624 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) {
11625         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
11626         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11627         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11628         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11629         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11630         LDKUserConfig config_conv;
11631         config_conv.inner = (void*)(config & (~1));
11632         config_conv.is_owned = (config & 1) || (config == 0);
11633         config_conv = UserConfig_clone(&config_conv);
11634         LDKChainParameters params_conv;
11635         params_conv.inner = (void*)(params & (~1));
11636         params_conv.is_owned = (params & 1) || (params == 0);
11637         // Warning: we need a move here but no clone is available for LDKChainParameters
11638         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
11639         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11640         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11641         long ret_ref = (long)ret_var.inner;
11642         if (ret_var.is_owned) {
11643                 ret_ref |= 1;
11644         }
11645         return ret_ref;
11646 }
11647
11648 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
11649         LDKChannelManager this_arg_conv;
11650         this_arg_conv.inner = (void*)(this_arg & (~1));
11651         this_arg_conv.is_owned = false;
11652         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
11653         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11654         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11655         long ret_ref = (long)ret_var.inner;
11656         if (ret_var.is_owned) {
11657                 ret_ref |= 1;
11658         }
11659         return ret_ref;
11660 }
11661
11662 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) {
11663         LDKChannelManager this_arg_conv;
11664         this_arg_conv.inner = (void*)(this_arg & (~1));
11665         this_arg_conv.is_owned = false;
11666         LDKPublicKey their_network_key_ref;
11667         CHECK(*((uint32_t*)their_network_key) == 33);
11668         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
11669         LDKUserConfig override_config_conv;
11670         override_config_conv.inner = (void*)(override_config & (~1));
11671         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
11672         override_config_conv = UserConfig_clone(&override_config_conv);
11673         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11674         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
11675         return (long)ret_conv;
11676 }
11677
11678 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
11679         LDKChannelManager this_arg_conv;
11680         this_arg_conv.inner = (void*)(this_arg & (~1));
11681         this_arg_conv.is_owned = false;
11682         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
11683         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11684         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11685         for (size_t q = 0; q < ret_var.datalen; q++) {
11686                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11687                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11688                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11689                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11690                 if (ret_conv_16_var.is_owned) {
11691                         ret_conv_16_ref |= 1;
11692                 }
11693                 ret_arr_ptr[q] = ret_conv_16_ref;
11694         }
11695         FREE(ret_var.data);
11696         return ret_arr;
11697 }
11698
11699 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
11700         LDKChannelManager this_arg_conv;
11701         this_arg_conv.inner = (void*)(this_arg & (~1));
11702         this_arg_conv.is_owned = false;
11703         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
11704         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11705         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11706         for (size_t q = 0; q < ret_var.datalen; q++) {
11707                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11708                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11709                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11710                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
11711                 if (ret_conv_16_var.is_owned) {
11712                         ret_conv_16_ref |= 1;
11713                 }
11714                 ret_arr_ptr[q] = ret_conv_16_ref;
11715         }
11716         FREE(ret_var.data);
11717         return ret_arr;
11718 }
11719
11720 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
11721         LDKChannelManager this_arg_conv;
11722         this_arg_conv.inner = (void*)(this_arg & (~1));
11723         this_arg_conv.is_owned = false;
11724         unsigned char channel_id_arr[32];
11725         CHECK(*((uint32_t*)channel_id) == 32);
11726         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
11727         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11728         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11729         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
11730         return (long)ret_conv;
11731 }
11732
11733 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
11734         LDKChannelManager this_arg_conv;
11735         this_arg_conv.inner = (void*)(this_arg & (~1));
11736         this_arg_conv.is_owned = false;
11737         unsigned char channel_id_arr[32];
11738         CHECK(*((uint32_t*)channel_id) == 32);
11739         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
11740         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
11741         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11742         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
11743         return (long)ret_conv;
11744 }
11745
11746 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
11747         LDKChannelManager this_arg_conv;
11748         this_arg_conv.inner = (void*)(this_arg & (~1));
11749         this_arg_conv.is_owned = false;
11750         ChannelManager_force_close_all_channels(&this_arg_conv);
11751 }
11752
11753 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
11754         LDKChannelManager this_arg_conv;
11755         this_arg_conv.inner = (void*)(this_arg & (~1));
11756         this_arg_conv.is_owned = false;
11757         LDKRoute route_conv;
11758         route_conv.inner = (void*)(route & (~1));
11759         route_conv.is_owned = false;
11760         LDKThirtyTwoBytes payment_hash_ref;
11761         CHECK(*((uint32_t*)payment_hash) == 32);
11762         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
11763         LDKThirtyTwoBytes payment_secret_ref;
11764         CHECK(*((uint32_t*)payment_secret) == 32);
11765         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11766         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11767         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
11768         return (long)ret_conv;
11769 }
11770
11771 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
11772         LDKChannelManager this_arg_conv;
11773         this_arg_conv.inner = (void*)(this_arg & (~1));
11774         this_arg_conv.is_owned = false;
11775         unsigned char temporary_channel_id_arr[32];
11776         CHECK(*((uint32_t*)temporary_channel_id) == 32);
11777         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
11778         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
11779         LDKTransaction funding_transaction_ref;
11780         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
11781         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
11782         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
11783         funding_transaction_ref.data_is_owned = true;
11784         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11785         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
11786         return (long)ret_conv;
11787 }
11788
11789 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
11790         LDKChannelManager this_arg_conv;
11791         this_arg_conv.inner = (void*)(this_arg & (~1));
11792         this_arg_conv.is_owned = false;
11793         LDKThreeBytes rgb_ref;
11794         CHECK(*((uint32_t*)rgb) == 3);
11795         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
11796         LDKThirtyTwoBytes alias_ref;
11797         CHECK(*((uint32_t*)alias) == 32);
11798         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
11799         LDKCVec_NetAddressZ addresses_constr;
11800         addresses_constr.datalen = *((uint32_t*)addresses);
11801         if (addresses_constr.datalen > 0)
11802                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11803         else
11804                 addresses_constr.data = NULL;
11805         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
11806         for (size_t m = 0; m < addresses_constr.datalen; m++) {
11807                 uint32_t addresses_conv_12 = addresses_vals[m];
11808                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
11809                 FREE((void*)addresses_conv_12);
11810                 addresses_constr.data[m] = addresses_conv_12_conv;
11811         }
11812         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
11813 }
11814
11815 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
11816         LDKChannelManager this_arg_conv;
11817         this_arg_conv.inner = (void*)(this_arg & (~1));
11818         this_arg_conv.is_owned = false;
11819         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11820 }
11821
11822 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
11823         LDKChannelManager this_arg_conv;
11824         this_arg_conv.inner = (void*)(this_arg & (~1));
11825         this_arg_conv.is_owned = false;
11826         ChannelManager_timer_tick_occurred(&this_arg_conv);
11827 }
11828
11829 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11830         LDKChannelManager this_arg_conv;
11831         this_arg_conv.inner = (void*)(this_arg & (~1));
11832         this_arg_conv.is_owned = false;
11833         unsigned char payment_hash_arr[32];
11834         CHECK(*((uint32_t*)payment_hash) == 32);
11835         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
11836         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11837         LDKThirtyTwoBytes payment_secret_ref;
11838         CHECK(*((uint32_t*)payment_secret) == 32);
11839         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11840         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11841         return ret_val;
11842 }
11843
11844 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11845         LDKChannelManager this_arg_conv;
11846         this_arg_conv.inner = (void*)(this_arg & (~1));
11847         this_arg_conv.is_owned = false;
11848         LDKThirtyTwoBytes payment_preimage_ref;
11849         CHECK(*((uint32_t*)payment_preimage) == 32);
11850         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11851         LDKThirtyTwoBytes payment_secret_ref;
11852         CHECK(*((uint32_t*)payment_secret) == 32);
11853         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11854         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
11855         return ret_val;
11856 }
11857
11858 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
11859         LDKChannelManager this_arg_conv;
11860         this_arg_conv.inner = (void*)(this_arg & (~1));
11861         this_arg_conv.is_owned = false;
11862         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11863         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
11864         return ret_arr;
11865 }
11866
11867 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
11868         LDKChannelManager this_arg_conv;
11869         this_arg_conv.inner = (void*)(this_arg & (~1));
11870         this_arg_conv.is_owned = false;
11871         LDKOutPoint funding_txo_conv;
11872         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11873         funding_txo_conv.is_owned = false;
11874         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
11875 }
11876
11877 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
11878         LDKChannelManager this_arg_conv;
11879         this_arg_conv.inner = (void*)(this_arg & (~1));
11880         this_arg_conv.is_owned = false;
11881         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11882         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
11883         return (long)ret;
11884 }
11885
11886 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
11887         LDKChannelManager this_arg_conv;
11888         this_arg_conv.inner = (void*)(this_arg & (~1));
11889         this_arg_conv.is_owned = false;
11890         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11891         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
11892         return (long)ret;
11893 }
11894
11895 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
11896         LDKChannelManager this_arg_conv;
11897         this_arg_conv.inner = (void*)(this_arg & (~1));
11898         this_arg_conv.is_owned = false;
11899         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11900         *ret = ChannelManager_as_Listen(&this_arg_conv);
11901         return (long)ret;
11902 }
11903
11904 void  __attribute__((visibility("default"))) TS_ChannelManager_transactions_confirmed(uint32_t this_arg, int8_tArray header, int32_t height, uint32_tArray txdata) {
11905         LDKChannelManager this_arg_conv;
11906         this_arg_conv.inner = (void*)(this_arg & (~1));
11907         this_arg_conv.is_owned = false;
11908         unsigned char header_arr[80];
11909         CHECK(*((uint32_t*)header) == 80);
11910         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11911         unsigned char (*header_ref)[80] = &header_arr;
11912         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11913         txdata_constr.datalen = *((uint32_t*)txdata);
11914         if (txdata_constr.datalen > 0)
11915                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11916         else
11917                 txdata_constr.data = NULL;
11918         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11919         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11920                 uint32_t txdata_conv_30 = txdata_vals[e];
11921                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11922                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_usizeTransactionZ
11923                 txdata_constr.data[e] = txdata_conv_30_conv;
11924         }
11925         ChannelManager_transactions_confirmed(&this_arg_conv, header_ref, height, txdata_constr);
11926 }
11927
11928 void  __attribute__((visibility("default"))) TS_ChannelManager_update_best_block(uint32_t this_arg, int8_tArray header, int32_t height) {
11929         LDKChannelManager this_arg_conv;
11930         this_arg_conv.inner = (void*)(this_arg & (~1));
11931         this_arg_conv.is_owned = false;
11932         unsigned char header_arr[80];
11933         CHECK(*((uint32_t*)header) == 80);
11934         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11935         unsigned char (*header_ref)[80] = &header_arr;
11936         ChannelManager_update_best_block(&this_arg_conv, header_ref, height);
11937 }
11938
11939 ptrArray  __attribute__((visibility("default"))) TS_ChannelManager_get_relevant_txids(uint32_t this_arg) {
11940         LDKChannelManager this_arg_conv;
11941         this_arg_conv.inner = (void*)(this_arg & (~1));
11942         this_arg_conv.is_owned = false;
11943         LDKCVec_TxidZ ret_var = ChannelManager_get_relevant_txids(&this_arg_conv);
11944         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11945         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11946         for (size_t m = 0; m < ret_var.datalen; m++) {
11947                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11948                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
11949                 ret_arr_ptr[m] = ret_conv_12_arr;
11950         }
11951         FREE(ret_var.data);
11952         return ret_arr;
11953 }
11954
11955 void  __attribute__((visibility("default"))) TS_ChannelManager_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
11956         LDKChannelManager this_arg_conv;
11957         this_arg_conv.inner = (void*)(this_arg & (~1));
11958         this_arg_conv.is_owned = false;
11959         unsigned char txid_arr[32];
11960         CHECK(*((uint32_t*)txid) == 32);
11961         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
11962         unsigned char (*txid_ref)[32] = &txid_arr;
11963         ChannelManager_transaction_unconfirmed(&this_arg_conv, txid_ref);
11964 }
11965
11966 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
11967         LDKChannelManager this_arg_conv;
11968         this_arg_conv.inner = (void*)(this_arg & (~1));
11969         this_arg_conv.is_owned = false;
11970         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
11971         return ret_val;
11972 }
11973
11974 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
11975         LDKChannelManager this_arg_conv;
11976         this_arg_conv.inner = (void*)(this_arg & (~1));
11977         this_arg_conv.is_owned = false;
11978         ChannelManager_await_persistable_update(&this_arg_conv);
11979 }
11980
11981 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
11982         LDKChannelManager this_arg_conv;
11983         this_arg_conv.inner = (void*)(this_arg & (~1));
11984         this_arg_conv.is_owned = false;
11985         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11986         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
11987         return (long)ret;
11988 }
11989
11990 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
11991         LDKChannelManager obj_conv;
11992         obj_conv.inner = (void*)(obj & (~1));
11993         obj_conv.is_owned = false;
11994         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
11995         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11996         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11997         CVec_u8Z_free(ret_var);
11998         return ret_arr;
11999 }
12000
12001 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
12002         LDKChannelManagerReadArgs this_obj_conv;
12003         this_obj_conv.inner = (void*)(this_obj & (~1));
12004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12005         ChannelManagerReadArgs_free(this_obj_conv);
12006 }
12007
12008 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
12009         LDKChannelManagerReadArgs this_ptr_conv;
12010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12011         this_ptr_conv.is_owned = false;
12012         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
12013         return ret_ret;
12014 }
12015
12016 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
12017         LDKChannelManagerReadArgs this_ptr_conv;
12018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12019         this_ptr_conv.is_owned = false;
12020         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
12021         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
12022 }
12023
12024 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
12025         LDKChannelManagerReadArgs this_ptr_conv;
12026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12027         this_ptr_conv.is_owned = false;
12028         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
12029         return ret_ret;
12030 }
12031
12032 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
12033         LDKChannelManagerReadArgs this_ptr_conv;
12034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12035         this_ptr_conv.is_owned = false;
12036         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
12037         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
12038 }
12039
12040 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
12041         LDKChannelManagerReadArgs this_ptr_conv;
12042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12043         this_ptr_conv.is_owned = false;
12044         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
12045         return ret_ret;
12046 }
12047
12048 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
12049         LDKChannelManagerReadArgs this_ptr_conv;
12050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12051         this_ptr_conv.is_owned = false;
12052         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
12053         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
12054 }
12055
12056 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
12057         LDKChannelManagerReadArgs this_ptr_conv;
12058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12059         this_ptr_conv.is_owned = false;
12060         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
12061         return ret_ret;
12062 }
12063
12064 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
12065         LDKChannelManagerReadArgs this_ptr_conv;
12066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12067         this_ptr_conv.is_owned = false;
12068         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
12069         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
12070 }
12071
12072 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
12073         LDKChannelManagerReadArgs this_ptr_conv;
12074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12075         this_ptr_conv.is_owned = false;
12076         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
12077         return ret_ret;
12078 }
12079
12080 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
12081         LDKChannelManagerReadArgs this_ptr_conv;
12082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12083         this_ptr_conv.is_owned = false;
12084         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
12085         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
12086 }
12087
12088 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
12089         LDKChannelManagerReadArgs this_ptr_conv;
12090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12091         this_ptr_conv.is_owned = false;
12092         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
12093         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12094         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12095         long ret_ref = (long)ret_var.inner;
12096         if (ret_var.is_owned) {
12097                 ret_ref |= 1;
12098         }
12099         return ret_ref;
12100 }
12101
12102 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
12103         LDKChannelManagerReadArgs this_ptr_conv;
12104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12105         this_ptr_conv.is_owned = false;
12106         LDKUserConfig val_conv;
12107         val_conv.inner = (void*)(val & (~1));
12108         val_conv.is_owned = (val & 1) || (val == 0);
12109         val_conv = UserConfig_clone(&val_conv);
12110         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
12111 }
12112
12113 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) {
12114         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
12115         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12116         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
12117         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
12118         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12119         LDKUserConfig default_config_conv;
12120         default_config_conv.inner = (void*)(default_config & (~1));
12121         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
12122         default_config_conv = UserConfig_clone(&default_config_conv);
12123         LDKCVec_ChannelMonitorZ channel_monitors_constr;
12124         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
12125         if (channel_monitors_constr.datalen > 0)
12126                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
12127         else
12128                 channel_monitors_constr.data = NULL;
12129         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
12130         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
12131                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
12132                 LDKChannelMonitor channel_monitors_conv_16_conv;
12133                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
12134                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
12135                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
12136         }
12137         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);
12138         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12139         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12140         long ret_ref = (long)ret_var.inner;
12141         if (ret_var.is_owned) {
12142                 ret_ref |= 1;
12143         }
12144         return ret_ref;
12145 }
12146
12147 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
12148         LDKu8slice ser_ref;
12149         ser_ref.datalen = *((uint32_t*)ser);
12150         ser_ref.data = (int8_t*)(ser + 4);
12151         LDKChannelManagerReadArgs arg_conv;
12152         arg_conv.inner = (void*)(arg & (~1));
12153         arg_conv.is_owned = (arg & 1) || (arg == 0);
12154         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
12155         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12156         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
12157         return (long)ret_conv;
12158 }
12159
12160 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
12161         LDKDecodeError this_obj_conv;
12162         this_obj_conv.inner = (void*)(this_obj & (~1));
12163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12164         DecodeError_free(this_obj_conv);
12165 }
12166
12167 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
12168         LDKDecodeError orig_conv;
12169         orig_conv.inner = (void*)(orig & (~1));
12170         orig_conv.is_owned = false;
12171         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
12172         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12173         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12174         long ret_ref = (long)ret_var.inner;
12175         if (ret_var.is_owned) {
12176                 ret_ref |= 1;
12177         }
12178         return ret_ref;
12179 }
12180
12181 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
12182         LDKInit this_obj_conv;
12183         this_obj_conv.inner = (void*)(this_obj & (~1));
12184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12185         Init_free(this_obj_conv);
12186 }
12187
12188 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
12189         LDKInit this_ptr_conv;
12190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12191         this_ptr_conv.is_owned = false;
12192         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
12193         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12194         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12195         long ret_ref = (long)ret_var.inner;
12196         if (ret_var.is_owned) {
12197                 ret_ref |= 1;
12198         }
12199         return ret_ref;
12200 }
12201
12202 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
12203         LDKInit this_ptr_conv;
12204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12205         this_ptr_conv.is_owned = false;
12206         LDKInitFeatures val_conv;
12207         val_conv.inner = (void*)(val & (~1));
12208         val_conv.is_owned = (val & 1) || (val == 0);
12209         val_conv = InitFeatures_clone(&val_conv);
12210         Init_set_features(&this_ptr_conv, val_conv);
12211 }
12212
12213 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
12214         LDKInitFeatures features_arg_conv;
12215         features_arg_conv.inner = (void*)(features_arg & (~1));
12216         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
12217         features_arg_conv = InitFeatures_clone(&features_arg_conv);
12218         LDKInit ret_var = Init_new(features_arg_conv);
12219         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12220         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12221         long ret_ref = (long)ret_var.inner;
12222         if (ret_var.is_owned) {
12223                 ret_ref |= 1;
12224         }
12225         return ret_ref;
12226 }
12227
12228 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
12229         LDKInit orig_conv;
12230         orig_conv.inner = (void*)(orig & (~1));
12231         orig_conv.is_owned = false;
12232         LDKInit ret_var = Init_clone(&orig_conv);
12233         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12234         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12235         long ret_ref = (long)ret_var.inner;
12236         if (ret_var.is_owned) {
12237                 ret_ref |= 1;
12238         }
12239         return ret_ref;
12240 }
12241
12242 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
12243         LDKErrorMessage this_obj_conv;
12244         this_obj_conv.inner = (void*)(this_obj & (~1));
12245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12246         ErrorMessage_free(this_obj_conv);
12247 }
12248
12249 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
12250         LDKErrorMessage this_ptr_conv;
12251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12252         this_ptr_conv.is_owned = false;
12253         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12254         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
12255         return ret_arr;
12256 }
12257
12258 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12259         LDKErrorMessage this_ptr_conv;
12260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12261         this_ptr_conv.is_owned = false;
12262         LDKThirtyTwoBytes val_ref;
12263         CHECK(*((uint32_t*)val) == 32);
12264         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12265         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
12266 }
12267
12268 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
12269         LDKErrorMessage this_ptr_conv;
12270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12271         this_ptr_conv.is_owned = false;
12272         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
12273         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
12274         return _conv;
12275 }
12276
12277 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
12278         LDKErrorMessage this_ptr_conv;
12279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12280         this_ptr_conv.is_owned = false;
12281         LDKCVec_u8Z val_ref;
12282         val_ref.datalen = *((uint32_t*)val);
12283         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12284         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
12285         ErrorMessage_set_data(&this_ptr_conv, val_ref);
12286 }
12287
12288 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
12289         LDKThirtyTwoBytes channel_id_arg_ref;
12290         CHECK(*((uint32_t*)channel_id_arg) == 32);
12291         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12292         LDKCVec_u8Z data_arg_ref;
12293         data_arg_ref.datalen = *((uint32_t*)data_arg);
12294         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12295         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
12296         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
12297         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12298         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12299         long ret_ref = (long)ret_var.inner;
12300         if (ret_var.is_owned) {
12301                 ret_ref |= 1;
12302         }
12303         return ret_ref;
12304 }
12305
12306 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
12307         LDKErrorMessage orig_conv;
12308         orig_conv.inner = (void*)(orig & (~1));
12309         orig_conv.is_owned = false;
12310         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
12311         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12312         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12313         long ret_ref = (long)ret_var.inner;
12314         if (ret_var.is_owned) {
12315                 ret_ref |= 1;
12316         }
12317         return ret_ref;
12318 }
12319
12320 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
12321         LDKPing this_obj_conv;
12322         this_obj_conv.inner = (void*)(this_obj & (~1));
12323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12324         Ping_free(this_obj_conv);
12325 }
12326
12327 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
12328         LDKPing this_ptr_conv;
12329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12330         this_ptr_conv.is_owned = false;
12331         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
12332         return ret_val;
12333 }
12334
12335 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
12336         LDKPing this_ptr_conv;
12337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12338         this_ptr_conv.is_owned = false;
12339         Ping_set_ponglen(&this_ptr_conv, val);
12340 }
12341
12342 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
12343         LDKPing this_ptr_conv;
12344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12345         this_ptr_conv.is_owned = false;
12346         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
12347         return ret_val;
12348 }
12349
12350 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
12351         LDKPing this_ptr_conv;
12352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12353         this_ptr_conv.is_owned = false;
12354         Ping_set_byteslen(&this_ptr_conv, val);
12355 }
12356
12357 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
12358         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
12359         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12360         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12361         long ret_ref = (long)ret_var.inner;
12362         if (ret_var.is_owned) {
12363                 ret_ref |= 1;
12364         }
12365         return ret_ref;
12366 }
12367
12368 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
12369         LDKPing orig_conv;
12370         orig_conv.inner = (void*)(orig & (~1));
12371         orig_conv.is_owned = false;
12372         LDKPing ret_var = Ping_clone(&orig_conv);
12373         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12374         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12375         long ret_ref = (long)ret_var.inner;
12376         if (ret_var.is_owned) {
12377                 ret_ref |= 1;
12378         }
12379         return ret_ref;
12380 }
12381
12382 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
12383         LDKPong this_obj_conv;
12384         this_obj_conv.inner = (void*)(this_obj & (~1));
12385         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12386         Pong_free(this_obj_conv);
12387 }
12388
12389 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
12390         LDKPong this_ptr_conv;
12391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12392         this_ptr_conv.is_owned = false;
12393         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
12394         return ret_val;
12395 }
12396
12397 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
12398         LDKPong this_ptr_conv;
12399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12400         this_ptr_conv.is_owned = false;
12401         Pong_set_byteslen(&this_ptr_conv, val);
12402 }
12403
12404 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
12405         LDKPong ret_var = Pong_new(byteslen_arg);
12406         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12407         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12408         long ret_ref = (long)ret_var.inner;
12409         if (ret_var.is_owned) {
12410                 ret_ref |= 1;
12411         }
12412         return ret_ref;
12413 }
12414
12415 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
12416         LDKPong orig_conv;
12417         orig_conv.inner = (void*)(orig & (~1));
12418         orig_conv.is_owned = false;
12419         LDKPong ret_var = Pong_clone(&orig_conv);
12420         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12421         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12422         long ret_ref = (long)ret_var.inner;
12423         if (ret_var.is_owned) {
12424                 ret_ref |= 1;
12425         }
12426         return ret_ref;
12427 }
12428
12429 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
12430         LDKOpenChannel this_obj_conv;
12431         this_obj_conv.inner = (void*)(this_obj & (~1));
12432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12433         OpenChannel_free(this_obj_conv);
12434 }
12435
12436 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
12437         LDKOpenChannel this_ptr_conv;
12438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12439         this_ptr_conv.is_owned = false;
12440         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12441         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
12442         return ret_arr;
12443 }
12444
12445 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
12446         LDKOpenChannel this_ptr_conv;
12447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12448         this_ptr_conv.is_owned = false;
12449         LDKThirtyTwoBytes val_ref;
12450         CHECK(*((uint32_t*)val) == 32);
12451         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12452         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
12453 }
12454
12455 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
12456         LDKOpenChannel this_ptr_conv;
12457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12458         this_ptr_conv.is_owned = false;
12459         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12460         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
12461         return ret_arr;
12462 }
12463
12464 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12465         LDKOpenChannel this_ptr_conv;
12466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12467         this_ptr_conv.is_owned = false;
12468         LDKThirtyTwoBytes val_ref;
12469         CHECK(*((uint32_t*)val) == 32);
12470         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12471         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12472 }
12473
12474 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
12475         LDKOpenChannel this_ptr_conv;
12476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12477         this_ptr_conv.is_owned = false;
12478         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
12479         return ret_val;
12480 }
12481
12482 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
12483         LDKOpenChannel this_ptr_conv;
12484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12485         this_ptr_conv.is_owned = false;
12486         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
12487 }
12488
12489 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
12490         LDKOpenChannel this_ptr_conv;
12491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12492         this_ptr_conv.is_owned = false;
12493         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
12494         return ret_val;
12495 }
12496
12497 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
12498         LDKOpenChannel this_ptr_conv;
12499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12500         this_ptr_conv.is_owned = false;
12501         OpenChannel_set_push_msat(&this_ptr_conv, val);
12502 }
12503
12504 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
12505         LDKOpenChannel this_ptr_conv;
12506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12507         this_ptr_conv.is_owned = false;
12508         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
12509         return ret_val;
12510 }
12511
12512 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
12513         LDKOpenChannel this_ptr_conv;
12514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12515         this_ptr_conv.is_owned = false;
12516         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12517 }
12518
12519 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12520         LDKOpenChannel this_ptr_conv;
12521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12522         this_ptr_conv.is_owned = false;
12523         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12524         return ret_val;
12525 }
12526
12527 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12528         LDKOpenChannel this_ptr_conv;
12529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12530         this_ptr_conv.is_owned = false;
12531         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12532 }
12533
12534 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
12535         LDKOpenChannel this_ptr_conv;
12536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12537         this_ptr_conv.is_owned = false;
12538         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12539         return ret_val;
12540 }
12541
12542 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12543         LDKOpenChannel this_ptr_conv;
12544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12545         this_ptr_conv.is_owned = false;
12546         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12547 }
12548
12549 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
12550         LDKOpenChannel this_ptr_conv;
12551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12552         this_ptr_conv.is_owned = false;
12553         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
12554         return ret_val;
12555 }
12556
12557 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12558         LDKOpenChannel this_ptr_conv;
12559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12560         this_ptr_conv.is_owned = false;
12561         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12562 }
12563
12564 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
12565         LDKOpenChannel this_ptr_conv;
12566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12567         this_ptr_conv.is_owned = false;
12568         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
12569         return ret_val;
12570 }
12571
12572 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
12573         LDKOpenChannel this_ptr_conv;
12574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12575         this_ptr_conv.is_owned = false;
12576         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
12577 }
12578
12579 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
12580         LDKOpenChannel this_ptr_conv;
12581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12582         this_ptr_conv.is_owned = false;
12583         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
12584         return ret_val;
12585 }
12586
12587 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12588         LDKOpenChannel this_ptr_conv;
12589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12590         this_ptr_conv.is_owned = false;
12591         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
12592 }
12593
12594 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12595         LDKOpenChannel this_ptr_conv;
12596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12597         this_ptr_conv.is_owned = false;
12598         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
12599         return ret_val;
12600 }
12601
12602 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12603         LDKOpenChannel this_ptr_conv;
12604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12605         this_ptr_conv.is_owned = false;
12606         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12607 }
12608
12609 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
12610         LDKOpenChannel this_ptr_conv;
12611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12612         this_ptr_conv.is_owned = false;
12613         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12614         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12615         return ret_arr;
12616 }
12617
12618 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12619         LDKOpenChannel this_ptr_conv;
12620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12621         this_ptr_conv.is_owned = false;
12622         LDKPublicKey val_ref;
12623         CHECK(*((uint32_t*)val) == 33);
12624         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12625         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12626 }
12627
12628 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
12629         LDKOpenChannel this_ptr_conv;
12630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12631         this_ptr_conv.is_owned = false;
12632         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12633         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12634         return ret_arr;
12635 }
12636
12637 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12638         LDKOpenChannel this_ptr_conv;
12639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12640         this_ptr_conv.is_owned = false;
12641         LDKPublicKey val_ref;
12642         CHECK(*((uint32_t*)val) == 33);
12643         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12644         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12645 }
12646
12647 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
12648         LDKOpenChannel this_ptr_conv;
12649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12650         this_ptr_conv.is_owned = false;
12651         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12652         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12653         return ret_arr;
12654 }
12655
12656 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12657         LDKOpenChannel this_ptr_conv;
12658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12659         this_ptr_conv.is_owned = false;
12660         LDKPublicKey val_ref;
12661         CHECK(*((uint32_t*)val) == 33);
12662         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12663         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
12664 }
12665
12666 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12667         LDKOpenChannel this_ptr_conv;
12668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12669         this_ptr_conv.is_owned = false;
12670         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12671         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12672         return ret_arr;
12673 }
12674
12675 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12676         LDKOpenChannel this_ptr_conv;
12677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12678         this_ptr_conv.is_owned = false;
12679         LDKPublicKey val_ref;
12680         CHECK(*((uint32_t*)val) == 33);
12681         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12682         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12683 }
12684
12685 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
12686         LDKOpenChannel this_ptr_conv;
12687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12688         this_ptr_conv.is_owned = false;
12689         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12690         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12691         return ret_arr;
12692 }
12693
12694 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12695         LDKOpenChannel this_ptr_conv;
12696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12697         this_ptr_conv.is_owned = false;
12698         LDKPublicKey val_ref;
12699         CHECK(*((uint32_t*)val) == 33);
12700         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12701         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12702 }
12703
12704 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12705         LDKOpenChannel this_ptr_conv;
12706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12707         this_ptr_conv.is_owned = false;
12708         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12709         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12710         return ret_arr;
12711 }
12712
12713 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12714         LDKOpenChannel this_ptr_conv;
12715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12716         this_ptr_conv.is_owned = false;
12717         LDKPublicKey val_ref;
12718         CHECK(*((uint32_t*)val) == 33);
12719         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12720         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12721 }
12722
12723 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
12724         LDKOpenChannel this_ptr_conv;
12725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12726         this_ptr_conv.is_owned = false;
12727         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
12728         return ret_val;
12729 }
12730
12731 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
12732         LDKOpenChannel this_ptr_conv;
12733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12734         this_ptr_conv.is_owned = false;
12735         OpenChannel_set_channel_flags(&this_ptr_conv, val);
12736 }
12737
12738 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
12739         LDKOpenChannel orig_conv;
12740         orig_conv.inner = (void*)(orig & (~1));
12741         orig_conv.is_owned = false;
12742         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
12743         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12744         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12745         long ret_ref = (long)ret_var.inner;
12746         if (ret_var.is_owned) {
12747                 ret_ref |= 1;
12748         }
12749         return ret_ref;
12750 }
12751
12752 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
12753         LDKAcceptChannel this_obj_conv;
12754         this_obj_conv.inner = (void*)(this_obj & (~1));
12755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12756         AcceptChannel_free(this_obj_conv);
12757 }
12758
12759 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
12760         LDKAcceptChannel this_ptr_conv;
12761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12762         this_ptr_conv.is_owned = false;
12763         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12764         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
12765         return ret_arr;
12766 }
12767
12768 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12769         LDKAcceptChannel this_ptr_conv;
12770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12771         this_ptr_conv.is_owned = false;
12772         LDKThirtyTwoBytes val_ref;
12773         CHECK(*((uint32_t*)val) == 32);
12774         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12775         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
12776 }
12777
12778 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
12779         LDKAcceptChannel this_ptr_conv;
12780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12781         this_ptr_conv.is_owned = false;
12782         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
12783         return ret_val;
12784 }
12785
12786 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
12787         LDKAcceptChannel this_ptr_conv;
12788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12789         this_ptr_conv.is_owned = false;
12790         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
12791 }
12792
12793 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12794         LDKAcceptChannel this_ptr_conv;
12795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12796         this_ptr_conv.is_owned = false;
12797         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
12798         return ret_val;
12799 }
12800
12801 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12802         LDKAcceptChannel this_ptr_conv;
12803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12804         this_ptr_conv.is_owned = false;
12805         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12806 }
12807
12808 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
12809         LDKAcceptChannel this_ptr_conv;
12810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12811         this_ptr_conv.is_owned = false;
12812         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12813         return ret_val;
12814 }
12815
12816 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12817         LDKAcceptChannel this_ptr_conv;
12818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12819         this_ptr_conv.is_owned = false;
12820         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12821 }
12822
12823 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
12824         LDKAcceptChannel this_ptr_conv;
12825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12826         this_ptr_conv.is_owned = false;
12827         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
12828         return ret_val;
12829 }
12830
12831 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12832         LDKAcceptChannel this_ptr_conv;
12833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12834         this_ptr_conv.is_owned = false;
12835         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12836 }
12837
12838 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
12839         LDKAcceptChannel this_ptr_conv;
12840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12841         this_ptr_conv.is_owned = false;
12842         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
12843         return ret_val;
12844 }
12845
12846 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
12847         LDKAcceptChannel this_ptr_conv;
12848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12849         this_ptr_conv.is_owned = false;
12850         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
12851 }
12852
12853 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
12854         LDKAcceptChannel this_ptr_conv;
12855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12856         this_ptr_conv.is_owned = false;
12857         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
12858         return ret_val;
12859 }
12860
12861 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12862         LDKAcceptChannel this_ptr_conv;
12863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12864         this_ptr_conv.is_owned = false;
12865         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
12866 }
12867
12868 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12869         LDKAcceptChannel this_ptr_conv;
12870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12871         this_ptr_conv.is_owned = false;
12872         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
12873         return ret_val;
12874 }
12875
12876 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12877         LDKAcceptChannel this_ptr_conv;
12878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12879         this_ptr_conv.is_owned = false;
12880         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12881 }
12882
12883 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
12884         LDKAcceptChannel this_ptr_conv;
12885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12886         this_ptr_conv.is_owned = false;
12887         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12888         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12889         return ret_arr;
12890 }
12891
12892 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12893         LDKAcceptChannel this_ptr_conv;
12894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12895         this_ptr_conv.is_owned = false;
12896         LDKPublicKey val_ref;
12897         CHECK(*((uint32_t*)val) == 33);
12898         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12899         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12900 }
12901
12902 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
12903         LDKAcceptChannel this_ptr_conv;
12904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12905         this_ptr_conv.is_owned = false;
12906         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12907         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12908         return ret_arr;
12909 }
12910
12911 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12912         LDKAcceptChannel this_ptr_conv;
12913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12914         this_ptr_conv.is_owned = false;
12915         LDKPublicKey val_ref;
12916         CHECK(*((uint32_t*)val) == 33);
12917         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12918         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12919 }
12920
12921 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
12922         LDKAcceptChannel this_ptr_conv;
12923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12924         this_ptr_conv.is_owned = false;
12925         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12926         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12927         return ret_arr;
12928 }
12929
12930 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12931         LDKAcceptChannel this_ptr_conv;
12932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12933         this_ptr_conv.is_owned = false;
12934         LDKPublicKey val_ref;
12935         CHECK(*((uint32_t*)val) == 33);
12936         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12937         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
12938 }
12939
12940 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12941         LDKAcceptChannel this_ptr_conv;
12942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12943         this_ptr_conv.is_owned = false;
12944         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12945         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12946         return ret_arr;
12947 }
12948
12949 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12950         LDKAcceptChannel this_ptr_conv;
12951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12952         this_ptr_conv.is_owned = false;
12953         LDKPublicKey val_ref;
12954         CHECK(*((uint32_t*)val) == 33);
12955         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12956         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12957 }
12958
12959 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
12960         LDKAcceptChannel this_ptr_conv;
12961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12962         this_ptr_conv.is_owned = false;
12963         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12964         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12965         return ret_arr;
12966 }
12967
12968 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12969         LDKAcceptChannel this_ptr_conv;
12970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12971         this_ptr_conv.is_owned = false;
12972         LDKPublicKey val_ref;
12973         CHECK(*((uint32_t*)val) == 33);
12974         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12975         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12976 }
12977
12978 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12979         LDKAcceptChannel this_ptr_conv;
12980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12981         this_ptr_conv.is_owned = false;
12982         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12983         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12984         return ret_arr;
12985 }
12986
12987 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12988         LDKAcceptChannel this_ptr_conv;
12989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12990         this_ptr_conv.is_owned = false;
12991         LDKPublicKey val_ref;
12992         CHECK(*((uint32_t*)val) == 33);
12993         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12994         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12995 }
12996
12997 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
12998         LDKAcceptChannel orig_conv;
12999         orig_conv.inner = (void*)(orig & (~1));
13000         orig_conv.is_owned = false;
13001         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
13002         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13003         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13004         long ret_ref = (long)ret_var.inner;
13005         if (ret_var.is_owned) {
13006                 ret_ref |= 1;
13007         }
13008         return ret_ref;
13009 }
13010
13011 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
13012         LDKFundingCreated this_obj_conv;
13013         this_obj_conv.inner = (void*)(this_obj & (~1));
13014         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13015         FundingCreated_free(this_obj_conv);
13016 }
13017
13018 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
13019         LDKFundingCreated this_ptr_conv;
13020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13021         this_ptr_conv.is_owned = false;
13022         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13023         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
13024         return ret_arr;
13025 }
13026
13027 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
13028         LDKFundingCreated this_ptr_conv;
13029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13030         this_ptr_conv.is_owned = false;
13031         LDKThirtyTwoBytes val_ref;
13032         CHECK(*((uint32_t*)val) == 32);
13033         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13034         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
13035 }
13036
13037 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
13038         LDKFundingCreated this_ptr_conv;
13039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13040         this_ptr_conv.is_owned = false;
13041         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13042         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
13043         return ret_arr;
13044 }
13045
13046 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
13047         LDKFundingCreated this_ptr_conv;
13048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13049         this_ptr_conv.is_owned = false;
13050         LDKThirtyTwoBytes val_ref;
13051         CHECK(*((uint32_t*)val) == 32);
13052         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13053         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
13054 }
13055
13056 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
13057         LDKFundingCreated this_ptr_conv;
13058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13059         this_ptr_conv.is_owned = false;
13060         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
13061         return ret_val;
13062 }
13063
13064 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
13065         LDKFundingCreated this_ptr_conv;
13066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13067         this_ptr_conv.is_owned = false;
13068         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
13069 }
13070
13071 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
13072         LDKFundingCreated this_ptr_conv;
13073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13074         this_ptr_conv.is_owned = false;
13075         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13076         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
13077         return ret_arr;
13078 }
13079
13080 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
13081         LDKFundingCreated this_ptr_conv;
13082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13083         this_ptr_conv.is_owned = false;
13084         LDKSignature val_ref;
13085         CHECK(*((uint32_t*)val) == 64);
13086         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13087         FundingCreated_set_signature(&this_ptr_conv, val_ref);
13088 }
13089
13090 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) {
13091         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
13092         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
13093         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
13094         LDKThirtyTwoBytes funding_txid_arg_ref;
13095         CHECK(*((uint32_t*)funding_txid_arg) == 32);
13096         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
13097         LDKSignature signature_arg_ref;
13098         CHECK(*((uint32_t*)signature_arg) == 64);
13099         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13100         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
13101         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13102         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13103         long ret_ref = (long)ret_var.inner;
13104         if (ret_var.is_owned) {
13105                 ret_ref |= 1;
13106         }
13107         return ret_ref;
13108 }
13109
13110 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
13111         LDKFundingCreated orig_conv;
13112         orig_conv.inner = (void*)(orig & (~1));
13113         orig_conv.is_owned = false;
13114         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
13115         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13116         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13117         long ret_ref = (long)ret_var.inner;
13118         if (ret_var.is_owned) {
13119                 ret_ref |= 1;
13120         }
13121         return ret_ref;
13122 }
13123
13124 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
13125         LDKFundingSigned this_obj_conv;
13126         this_obj_conv.inner = (void*)(this_obj & (~1));
13127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13128         FundingSigned_free(this_obj_conv);
13129 }
13130
13131 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
13132         LDKFundingSigned this_ptr_conv;
13133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13134         this_ptr_conv.is_owned = false;
13135         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13136         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
13137         return ret_arr;
13138 }
13139
13140 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13141         LDKFundingSigned this_ptr_conv;
13142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13143         this_ptr_conv.is_owned = false;
13144         LDKThirtyTwoBytes val_ref;
13145         CHECK(*((uint32_t*)val) == 32);
13146         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13147         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
13148 }
13149
13150 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
13151         LDKFundingSigned this_ptr_conv;
13152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13153         this_ptr_conv.is_owned = false;
13154         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13155         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
13156         return ret_arr;
13157 }
13158
13159 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
13160         LDKFundingSigned this_ptr_conv;
13161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13162         this_ptr_conv.is_owned = false;
13163         LDKSignature val_ref;
13164         CHECK(*((uint32_t*)val) == 64);
13165         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13166         FundingSigned_set_signature(&this_ptr_conv, val_ref);
13167 }
13168
13169 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
13170         LDKThirtyTwoBytes channel_id_arg_ref;
13171         CHECK(*((uint32_t*)channel_id_arg) == 32);
13172         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13173         LDKSignature signature_arg_ref;
13174         CHECK(*((uint32_t*)signature_arg) == 64);
13175         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13176         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
13177         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13178         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13179         long ret_ref = (long)ret_var.inner;
13180         if (ret_var.is_owned) {
13181                 ret_ref |= 1;
13182         }
13183         return ret_ref;
13184 }
13185
13186 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
13187         LDKFundingSigned orig_conv;
13188         orig_conv.inner = (void*)(orig & (~1));
13189         orig_conv.is_owned = false;
13190         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
13191         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13192         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13193         long ret_ref = (long)ret_var.inner;
13194         if (ret_var.is_owned) {
13195                 ret_ref |= 1;
13196         }
13197         return ret_ref;
13198 }
13199
13200 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
13201         LDKFundingLocked this_obj_conv;
13202         this_obj_conv.inner = (void*)(this_obj & (~1));
13203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13204         FundingLocked_free(this_obj_conv);
13205 }
13206
13207 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
13208         LDKFundingLocked this_ptr_conv;
13209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13210         this_ptr_conv.is_owned = false;
13211         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13212         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
13213         return ret_arr;
13214 }
13215
13216 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13217         LDKFundingLocked this_ptr_conv;
13218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13219         this_ptr_conv.is_owned = false;
13220         LDKThirtyTwoBytes val_ref;
13221         CHECK(*((uint32_t*)val) == 32);
13222         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13223         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
13224 }
13225
13226 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
13227         LDKFundingLocked this_ptr_conv;
13228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13229         this_ptr_conv.is_owned = false;
13230         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13231         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13232         return ret_arr;
13233 }
13234
13235 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13236         LDKFundingLocked this_ptr_conv;
13237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13238         this_ptr_conv.is_owned = false;
13239         LDKPublicKey val_ref;
13240         CHECK(*((uint32_t*)val) == 33);
13241         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13242         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13243 }
13244
13245 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
13246         LDKThirtyTwoBytes channel_id_arg_ref;
13247         CHECK(*((uint32_t*)channel_id_arg) == 32);
13248         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13249         LDKPublicKey next_per_commitment_point_arg_ref;
13250         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
13251         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
13252         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
13253         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13254         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13255         long ret_ref = (long)ret_var.inner;
13256         if (ret_var.is_owned) {
13257                 ret_ref |= 1;
13258         }
13259         return ret_ref;
13260 }
13261
13262 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
13263         LDKFundingLocked orig_conv;
13264         orig_conv.inner = (void*)(orig & (~1));
13265         orig_conv.is_owned = false;
13266         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
13267         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13268         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13269         long ret_ref = (long)ret_var.inner;
13270         if (ret_var.is_owned) {
13271                 ret_ref |= 1;
13272         }
13273         return ret_ref;
13274 }
13275
13276 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
13277         LDKShutdown this_obj_conv;
13278         this_obj_conv.inner = (void*)(this_obj & (~1));
13279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13280         Shutdown_free(this_obj_conv);
13281 }
13282
13283 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
13284         LDKShutdown this_ptr_conv;
13285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13286         this_ptr_conv.is_owned = false;
13287         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13288         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
13289         return ret_arr;
13290 }
13291
13292 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13293         LDKShutdown this_ptr_conv;
13294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13295         this_ptr_conv.is_owned = false;
13296         LDKThirtyTwoBytes val_ref;
13297         CHECK(*((uint32_t*)val) == 32);
13298         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13299         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
13300 }
13301
13302 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
13303         LDKShutdown this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
13307         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13308         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13309         return ret_arr;
13310 }
13311
13312 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
13313         LDKShutdown this_ptr_conv;
13314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13315         this_ptr_conv.is_owned = false;
13316         LDKCVec_u8Z val_ref;
13317         val_ref.datalen = *((uint32_t*)val);
13318         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13319         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
13320         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
13321 }
13322
13323 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
13324         LDKThirtyTwoBytes channel_id_arg_ref;
13325         CHECK(*((uint32_t*)channel_id_arg) == 32);
13326         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13327         LDKCVec_u8Z scriptpubkey_arg_ref;
13328         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
13329         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13330         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
13331         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
13332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13334         long ret_ref = (long)ret_var.inner;
13335         if (ret_var.is_owned) {
13336                 ret_ref |= 1;
13337         }
13338         return ret_ref;
13339 }
13340
13341 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
13342         LDKShutdown orig_conv;
13343         orig_conv.inner = (void*)(orig & (~1));
13344         orig_conv.is_owned = false;
13345         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
13346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13348         long ret_ref = (long)ret_var.inner;
13349         if (ret_var.is_owned) {
13350                 ret_ref |= 1;
13351         }
13352         return ret_ref;
13353 }
13354
13355 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
13356         LDKClosingSigned this_obj_conv;
13357         this_obj_conv.inner = (void*)(this_obj & (~1));
13358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13359         ClosingSigned_free(this_obj_conv);
13360 }
13361
13362 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
13363         LDKClosingSigned this_ptr_conv;
13364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13365         this_ptr_conv.is_owned = false;
13366         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13367         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
13368         return ret_arr;
13369 }
13370
13371 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13372         LDKClosingSigned this_ptr_conv;
13373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13374         this_ptr_conv.is_owned = false;
13375         LDKThirtyTwoBytes val_ref;
13376         CHECK(*((uint32_t*)val) == 32);
13377         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13378         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
13379 }
13380
13381 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
13382         LDKClosingSigned this_ptr_conv;
13383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13384         this_ptr_conv.is_owned = false;
13385         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
13386         return ret_val;
13387 }
13388
13389 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
13390         LDKClosingSigned this_ptr_conv;
13391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13392         this_ptr_conv.is_owned = false;
13393         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
13394 }
13395
13396 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
13397         LDKClosingSigned this_ptr_conv;
13398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13399         this_ptr_conv.is_owned = false;
13400         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13401         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
13402         return ret_arr;
13403 }
13404
13405 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
13406         LDKClosingSigned this_ptr_conv;
13407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13408         this_ptr_conv.is_owned = false;
13409         LDKSignature val_ref;
13410         CHECK(*((uint32_t*)val) == 64);
13411         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13412         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
13413 }
13414
13415 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
13416         LDKThirtyTwoBytes channel_id_arg_ref;
13417         CHECK(*((uint32_t*)channel_id_arg) == 32);
13418         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13419         LDKSignature signature_arg_ref;
13420         CHECK(*((uint32_t*)signature_arg) == 64);
13421         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13422         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
13423         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13424         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13425         long ret_ref = (long)ret_var.inner;
13426         if (ret_var.is_owned) {
13427                 ret_ref |= 1;
13428         }
13429         return ret_ref;
13430 }
13431
13432 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
13433         LDKClosingSigned orig_conv;
13434         orig_conv.inner = (void*)(orig & (~1));
13435         orig_conv.is_owned = false;
13436         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
13437         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13438         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13439         long ret_ref = (long)ret_var.inner;
13440         if (ret_var.is_owned) {
13441                 ret_ref |= 1;
13442         }
13443         return ret_ref;
13444 }
13445
13446 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
13447         LDKUpdateAddHTLC this_obj_conv;
13448         this_obj_conv.inner = (void*)(this_obj & (~1));
13449         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13450         UpdateAddHTLC_free(this_obj_conv);
13451 }
13452
13453 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
13454         LDKUpdateAddHTLC this_ptr_conv;
13455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13456         this_ptr_conv.is_owned = false;
13457         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13458         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
13459         return ret_arr;
13460 }
13461
13462 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13463         LDKUpdateAddHTLC this_ptr_conv;
13464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13465         this_ptr_conv.is_owned = false;
13466         LDKThirtyTwoBytes val_ref;
13467         CHECK(*((uint32_t*)val) == 32);
13468         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13469         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
13470 }
13471
13472 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
13473         LDKUpdateAddHTLC this_ptr_conv;
13474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13475         this_ptr_conv.is_owned = false;
13476         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
13477         return ret_val;
13478 }
13479
13480 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13481         LDKUpdateAddHTLC this_ptr_conv;
13482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13483         this_ptr_conv.is_owned = false;
13484         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
13485 }
13486
13487 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
13488         LDKUpdateAddHTLC this_ptr_conv;
13489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13490         this_ptr_conv.is_owned = false;
13491         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
13492         return ret_val;
13493 }
13494
13495 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
13496         LDKUpdateAddHTLC this_ptr_conv;
13497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13498         this_ptr_conv.is_owned = false;
13499         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
13500 }
13501
13502 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
13503         LDKUpdateAddHTLC this_ptr_conv;
13504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13505         this_ptr_conv.is_owned = false;
13506         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13507         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
13508         return ret_arr;
13509 }
13510
13511 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
13512         LDKUpdateAddHTLC this_ptr_conv;
13513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13514         this_ptr_conv.is_owned = false;
13515         LDKThirtyTwoBytes val_ref;
13516         CHECK(*((uint32_t*)val) == 32);
13517         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13518         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
13519 }
13520
13521 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
13522         LDKUpdateAddHTLC this_ptr_conv;
13523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13524         this_ptr_conv.is_owned = false;
13525         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
13526         return ret_val;
13527 }
13528
13529 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
13530         LDKUpdateAddHTLC this_ptr_conv;
13531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13532         this_ptr_conv.is_owned = false;
13533         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
13534 }
13535
13536 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
13537         LDKUpdateAddHTLC orig_conv;
13538         orig_conv.inner = (void*)(orig & (~1));
13539         orig_conv.is_owned = false;
13540         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
13541         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13542         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13543         long ret_ref = (long)ret_var.inner;
13544         if (ret_var.is_owned) {
13545                 ret_ref |= 1;
13546         }
13547         return ret_ref;
13548 }
13549
13550 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
13551         LDKUpdateFulfillHTLC this_obj_conv;
13552         this_obj_conv.inner = (void*)(this_obj & (~1));
13553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13554         UpdateFulfillHTLC_free(this_obj_conv);
13555 }
13556
13557 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
13558         LDKUpdateFulfillHTLC this_ptr_conv;
13559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13560         this_ptr_conv.is_owned = false;
13561         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13562         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
13563         return ret_arr;
13564 }
13565
13566 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13567         LDKUpdateFulfillHTLC this_ptr_conv;
13568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13569         this_ptr_conv.is_owned = false;
13570         LDKThirtyTwoBytes val_ref;
13571         CHECK(*((uint32_t*)val) == 32);
13572         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13573         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
13574 }
13575
13576 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
13577         LDKUpdateFulfillHTLC this_ptr_conv;
13578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13579         this_ptr_conv.is_owned = false;
13580         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
13581         return ret_val;
13582 }
13583
13584 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13585         LDKUpdateFulfillHTLC this_ptr_conv;
13586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13587         this_ptr_conv.is_owned = false;
13588         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
13589 }
13590
13591 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
13592         LDKUpdateFulfillHTLC this_ptr_conv;
13593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13594         this_ptr_conv.is_owned = false;
13595         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13596         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
13597         return ret_arr;
13598 }
13599
13600 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
13601         LDKUpdateFulfillHTLC this_ptr_conv;
13602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13603         this_ptr_conv.is_owned = false;
13604         LDKThirtyTwoBytes val_ref;
13605         CHECK(*((uint32_t*)val) == 32);
13606         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13607         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
13608 }
13609
13610 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
13611         LDKThirtyTwoBytes channel_id_arg_ref;
13612         CHECK(*((uint32_t*)channel_id_arg) == 32);
13613         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13614         LDKThirtyTwoBytes payment_preimage_arg_ref;
13615         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
13616         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
13617         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
13618         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13619         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13620         long ret_ref = (long)ret_var.inner;
13621         if (ret_var.is_owned) {
13622                 ret_ref |= 1;
13623         }
13624         return ret_ref;
13625 }
13626
13627 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
13628         LDKUpdateFulfillHTLC orig_conv;
13629         orig_conv.inner = (void*)(orig & (~1));
13630         orig_conv.is_owned = false;
13631         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
13632         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13633         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13634         long ret_ref = (long)ret_var.inner;
13635         if (ret_var.is_owned) {
13636                 ret_ref |= 1;
13637         }
13638         return ret_ref;
13639 }
13640
13641 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
13642         LDKUpdateFailHTLC this_obj_conv;
13643         this_obj_conv.inner = (void*)(this_obj & (~1));
13644         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13645         UpdateFailHTLC_free(this_obj_conv);
13646 }
13647
13648 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
13649         LDKUpdateFailHTLC this_ptr_conv;
13650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13651         this_ptr_conv.is_owned = false;
13652         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13653         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
13654         return ret_arr;
13655 }
13656
13657 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13658         LDKUpdateFailHTLC this_ptr_conv;
13659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13660         this_ptr_conv.is_owned = false;
13661         LDKThirtyTwoBytes val_ref;
13662         CHECK(*((uint32_t*)val) == 32);
13663         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13664         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
13665 }
13666
13667 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
13668         LDKUpdateFailHTLC this_ptr_conv;
13669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13670         this_ptr_conv.is_owned = false;
13671         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
13672         return ret_val;
13673 }
13674
13675 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13676         LDKUpdateFailHTLC this_ptr_conv;
13677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13678         this_ptr_conv.is_owned = false;
13679         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
13680 }
13681
13682 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
13683         LDKUpdateFailHTLC orig_conv;
13684         orig_conv.inner = (void*)(orig & (~1));
13685         orig_conv.is_owned = false;
13686         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
13687         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13688         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13689         long ret_ref = (long)ret_var.inner;
13690         if (ret_var.is_owned) {
13691                 ret_ref |= 1;
13692         }
13693         return ret_ref;
13694 }
13695
13696 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
13697         LDKUpdateFailMalformedHTLC this_obj_conv;
13698         this_obj_conv.inner = (void*)(this_obj & (~1));
13699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13700         UpdateFailMalformedHTLC_free(this_obj_conv);
13701 }
13702
13703 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
13704         LDKUpdateFailMalformedHTLC this_ptr_conv;
13705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13706         this_ptr_conv.is_owned = false;
13707         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13708         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
13709         return ret_arr;
13710 }
13711
13712 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13713         LDKUpdateFailMalformedHTLC this_ptr_conv;
13714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13715         this_ptr_conv.is_owned = false;
13716         LDKThirtyTwoBytes val_ref;
13717         CHECK(*((uint32_t*)val) == 32);
13718         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13719         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
13720 }
13721
13722 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
13723         LDKUpdateFailMalformedHTLC this_ptr_conv;
13724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13725         this_ptr_conv.is_owned = false;
13726         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
13727         return ret_val;
13728 }
13729
13730 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
13731         LDKUpdateFailMalformedHTLC this_ptr_conv;
13732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13733         this_ptr_conv.is_owned = false;
13734         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
13735 }
13736
13737 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
13738         LDKUpdateFailMalformedHTLC this_ptr_conv;
13739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13740         this_ptr_conv.is_owned = false;
13741         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
13742         return ret_val;
13743 }
13744
13745 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
13746         LDKUpdateFailMalformedHTLC this_ptr_conv;
13747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13748         this_ptr_conv.is_owned = false;
13749         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
13750 }
13751
13752 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
13753         LDKUpdateFailMalformedHTLC orig_conv;
13754         orig_conv.inner = (void*)(orig & (~1));
13755         orig_conv.is_owned = false;
13756         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
13757         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13758         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13759         long ret_ref = (long)ret_var.inner;
13760         if (ret_var.is_owned) {
13761                 ret_ref |= 1;
13762         }
13763         return ret_ref;
13764 }
13765
13766 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
13767         LDKCommitmentSigned this_obj_conv;
13768         this_obj_conv.inner = (void*)(this_obj & (~1));
13769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13770         CommitmentSigned_free(this_obj_conv);
13771 }
13772
13773 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
13774         LDKCommitmentSigned this_ptr_conv;
13775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13776         this_ptr_conv.is_owned = false;
13777         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13778         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
13779         return ret_arr;
13780 }
13781
13782 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13783         LDKCommitmentSigned this_ptr_conv;
13784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13785         this_ptr_conv.is_owned = false;
13786         LDKThirtyTwoBytes val_ref;
13787         CHECK(*((uint32_t*)val) == 32);
13788         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13789         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
13790 }
13791
13792 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
13793         LDKCommitmentSigned this_ptr_conv;
13794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13795         this_ptr_conv.is_owned = false;
13796         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13797         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
13798         return ret_arr;
13799 }
13800
13801 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
13802         LDKCommitmentSigned this_ptr_conv;
13803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13804         this_ptr_conv.is_owned = false;
13805         LDKSignature val_ref;
13806         CHECK(*((uint32_t*)val) == 64);
13807         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13808         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
13809 }
13810
13811 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
13812         LDKCommitmentSigned this_ptr_conv;
13813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13814         this_ptr_conv.is_owned = false;
13815         LDKCVec_SignatureZ val_constr;
13816         val_constr.datalen = *((uint32_t*)val);
13817         if (val_constr.datalen > 0)
13818                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13819         else
13820                 val_constr.data = NULL;
13821         int8_tArray* val_vals = (int8_tArray*)(val + 4);
13822         for (size_t m = 0; m < val_constr.datalen; m++) {
13823                 int8_tArray val_conv_12 = val_vals[m];
13824                 LDKSignature val_conv_12_ref;
13825                 CHECK(*((uint32_t*)val_conv_12) == 64);
13826                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
13827                 val_constr.data[m] = val_conv_12_ref;
13828         }
13829         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
13830 }
13831
13832 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
13833         LDKThirtyTwoBytes channel_id_arg_ref;
13834         CHECK(*((uint32_t*)channel_id_arg) == 32);
13835         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13836         LDKSignature signature_arg_ref;
13837         CHECK(*((uint32_t*)signature_arg) == 64);
13838         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13839         LDKCVec_SignatureZ htlc_signatures_arg_constr;
13840         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
13841         if (htlc_signatures_arg_constr.datalen > 0)
13842                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13843         else
13844                 htlc_signatures_arg_constr.data = NULL;
13845         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
13846         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
13847                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
13848                 LDKSignature htlc_signatures_arg_conv_12_ref;
13849                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
13850                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
13851                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
13852         }
13853         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
13854         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13855         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13856         long ret_ref = (long)ret_var.inner;
13857         if (ret_var.is_owned) {
13858                 ret_ref |= 1;
13859         }
13860         return ret_ref;
13861 }
13862
13863 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
13864         LDKCommitmentSigned orig_conv;
13865         orig_conv.inner = (void*)(orig & (~1));
13866         orig_conv.is_owned = false;
13867         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
13868         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13869         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13870         long ret_ref = (long)ret_var.inner;
13871         if (ret_var.is_owned) {
13872                 ret_ref |= 1;
13873         }
13874         return ret_ref;
13875 }
13876
13877 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
13878         LDKRevokeAndACK this_obj_conv;
13879         this_obj_conv.inner = (void*)(this_obj & (~1));
13880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13881         RevokeAndACK_free(this_obj_conv);
13882 }
13883
13884 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
13885         LDKRevokeAndACK this_ptr_conv;
13886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13887         this_ptr_conv.is_owned = false;
13888         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13889         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
13890         return ret_arr;
13891 }
13892
13893 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13894         LDKRevokeAndACK this_ptr_conv;
13895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13896         this_ptr_conv.is_owned = false;
13897         LDKThirtyTwoBytes val_ref;
13898         CHECK(*((uint32_t*)val) == 32);
13899         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13900         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
13901 }
13902
13903 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
13904         LDKRevokeAndACK this_ptr_conv;
13905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13906         this_ptr_conv.is_owned = false;
13907         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13908         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
13909         return ret_arr;
13910 }
13911
13912 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13913         LDKRevokeAndACK this_ptr_conv;
13914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13915         this_ptr_conv.is_owned = false;
13916         LDKThirtyTwoBytes val_ref;
13917         CHECK(*((uint32_t*)val) == 32);
13918         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13919         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
13920 }
13921
13922 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
13923         LDKRevokeAndACK this_ptr_conv;
13924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13925         this_ptr_conv.is_owned = false;
13926         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13927         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13928         return ret_arr;
13929 }
13930
13931 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13932         LDKRevokeAndACK this_ptr_conv;
13933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13934         this_ptr_conv.is_owned = false;
13935         LDKPublicKey val_ref;
13936         CHECK(*((uint32_t*)val) == 33);
13937         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13938         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13939 }
13940
13941 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) {
13942         LDKThirtyTwoBytes channel_id_arg_ref;
13943         CHECK(*((uint32_t*)channel_id_arg) == 32);
13944         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13945         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
13946         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
13947         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
13948         LDKPublicKey next_per_commitment_point_arg_ref;
13949         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
13950         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
13951         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
13952         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13953         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13954         long ret_ref = (long)ret_var.inner;
13955         if (ret_var.is_owned) {
13956                 ret_ref |= 1;
13957         }
13958         return ret_ref;
13959 }
13960
13961 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
13962         LDKRevokeAndACK orig_conv;
13963         orig_conv.inner = (void*)(orig & (~1));
13964         orig_conv.is_owned = false;
13965         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
13966         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13967         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13968         long ret_ref = (long)ret_var.inner;
13969         if (ret_var.is_owned) {
13970                 ret_ref |= 1;
13971         }
13972         return ret_ref;
13973 }
13974
13975 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
13976         LDKUpdateFee this_obj_conv;
13977         this_obj_conv.inner = (void*)(this_obj & (~1));
13978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13979         UpdateFee_free(this_obj_conv);
13980 }
13981
13982 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
13983         LDKUpdateFee this_ptr_conv;
13984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13985         this_ptr_conv.is_owned = false;
13986         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13987         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
13988         return ret_arr;
13989 }
13990
13991 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13992         LDKUpdateFee this_ptr_conv;
13993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13994         this_ptr_conv.is_owned = false;
13995         LDKThirtyTwoBytes val_ref;
13996         CHECK(*((uint32_t*)val) == 32);
13997         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13998         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
13999 }
14000
14001 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
14002         LDKUpdateFee this_ptr_conv;
14003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14004         this_ptr_conv.is_owned = false;
14005         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
14006         return ret_val;
14007 }
14008
14009 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
14010         LDKUpdateFee this_ptr_conv;
14011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14012         this_ptr_conv.is_owned = false;
14013         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
14014 }
14015
14016 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
14017         LDKThirtyTwoBytes channel_id_arg_ref;
14018         CHECK(*((uint32_t*)channel_id_arg) == 32);
14019         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14020         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
14021         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14022         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14023         long ret_ref = (long)ret_var.inner;
14024         if (ret_var.is_owned) {
14025                 ret_ref |= 1;
14026         }
14027         return ret_ref;
14028 }
14029
14030 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
14031         LDKUpdateFee orig_conv;
14032         orig_conv.inner = (void*)(orig & (~1));
14033         orig_conv.is_owned = false;
14034         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
14035         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14036         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14037         long ret_ref = (long)ret_var.inner;
14038         if (ret_var.is_owned) {
14039                 ret_ref |= 1;
14040         }
14041         return ret_ref;
14042 }
14043
14044 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
14045         LDKDataLossProtect this_obj_conv;
14046         this_obj_conv.inner = (void*)(this_obj & (~1));
14047         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14048         DataLossProtect_free(this_obj_conv);
14049 }
14050
14051 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
14052         LDKDataLossProtect this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14056         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
14057         return ret_arr;
14058 }
14059
14060 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
14061         LDKDataLossProtect this_ptr_conv;
14062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14063         this_ptr_conv.is_owned = false;
14064         LDKThirtyTwoBytes val_ref;
14065         CHECK(*((uint32_t*)val) == 32);
14066         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14067         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
14068 }
14069
14070 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
14071         LDKDataLossProtect this_ptr_conv;
14072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14073         this_ptr_conv.is_owned = false;
14074         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14075         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14076         return ret_arr;
14077 }
14078
14079 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14080         LDKDataLossProtect this_ptr_conv;
14081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14082         this_ptr_conv.is_owned = false;
14083         LDKPublicKey val_ref;
14084         CHECK(*((uint32_t*)val) == 33);
14085         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14086         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
14087 }
14088
14089 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
14090         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
14091         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
14092         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
14093         LDKPublicKey my_current_per_commitment_point_arg_ref;
14094         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
14095         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
14096         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
14097         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14098         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14099         long ret_ref = (long)ret_var.inner;
14100         if (ret_var.is_owned) {
14101                 ret_ref |= 1;
14102         }
14103         return ret_ref;
14104 }
14105
14106 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
14107         LDKDataLossProtect orig_conv;
14108         orig_conv.inner = (void*)(orig & (~1));
14109         orig_conv.is_owned = false;
14110         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
14111         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14112         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14113         long ret_ref = (long)ret_var.inner;
14114         if (ret_var.is_owned) {
14115                 ret_ref |= 1;
14116         }
14117         return ret_ref;
14118 }
14119
14120 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
14121         LDKChannelReestablish this_obj_conv;
14122         this_obj_conv.inner = (void*)(this_obj & (~1));
14123         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14124         ChannelReestablish_free(this_obj_conv);
14125 }
14126
14127 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
14128         LDKChannelReestablish this_ptr_conv;
14129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14130         this_ptr_conv.is_owned = false;
14131         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14132         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
14133         return ret_arr;
14134 }
14135
14136 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14137         LDKChannelReestablish this_ptr_conv;
14138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14139         this_ptr_conv.is_owned = false;
14140         LDKThirtyTwoBytes val_ref;
14141         CHECK(*((uint32_t*)val) == 32);
14142         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14143         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
14144 }
14145
14146 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
14147         LDKChannelReestablish this_ptr_conv;
14148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14149         this_ptr_conv.is_owned = false;
14150         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
14151         return ret_val;
14152 }
14153
14154 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
14155         LDKChannelReestablish this_ptr_conv;
14156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14157         this_ptr_conv.is_owned = false;
14158         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
14159 }
14160
14161 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
14162         LDKChannelReestablish this_ptr_conv;
14163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14164         this_ptr_conv.is_owned = false;
14165         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
14166         return ret_val;
14167 }
14168
14169 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
14170         LDKChannelReestablish this_ptr_conv;
14171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14172         this_ptr_conv.is_owned = false;
14173         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
14174 }
14175
14176 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
14177         LDKChannelReestablish orig_conv;
14178         orig_conv.inner = (void*)(orig & (~1));
14179         orig_conv.is_owned = false;
14180         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
14181         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14182         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14183         long ret_ref = (long)ret_var.inner;
14184         if (ret_var.is_owned) {
14185                 ret_ref |= 1;
14186         }
14187         return ret_ref;
14188 }
14189
14190 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
14191         LDKAnnouncementSignatures this_obj_conv;
14192         this_obj_conv.inner = (void*)(this_obj & (~1));
14193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14194         AnnouncementSignatures_free(this_obj_conv);
14195 }
14196
14197 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
14198         LDKAnnouncementSignatures this_ptr_conv;
14199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14200         this_ptr_conv.is_owned = false;
14201         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14202         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
14203         return ret_arr;
14204 }
14205
14206 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14207         LDKAnnouncementSignatures this_ptr_conv;
14208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14209         this_ptr_conv.is_owned = false;
14210         LDKThirtyTwoBytes val_ref;
14211         CHECK(*((uint32_t*)val) == 32);
14212         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14213         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
14214 }
14215
14216 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
14217         LDKAnnouncementSignatures this_ptr_conv;
14218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14219         this_ptr_conv.is_owned = false;
14220         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
14221         return ret_val;
14222 }
14223
14224 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14225         LDKAnnouncementSignatures this_ptr_conv;
14226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14227         this_ptr_conv.is_owned = false;
14228         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
14229 }
14230
14231 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
14232         LDKAnnouncementSignatures this_ptr_conv;
14233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14234         this_ptr_conv.is_owned = false;
14235         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14236         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
14237         return ret_arr;
14238 }
14239
14240 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
14241         LDKAnnouncementSignatures this_ptr_conv;
14242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14243         this_ptr_conv.is_owned = false;
14244         LDKSignature val_ref;
14245         CHECK(*((uint32_t*)val) == 64);
14246         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14247         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
14248 }
14249
14250 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
14251         LDKAnnouncementSignatures this_ptr_conv;
14252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14253         this_ptr_conv.is_owned = false;
14254         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14255         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
14256         return ret_arr;
14257 }
14258
14259 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
14260         LDKAnnouncementSignatures this_ptr_conv;
14261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14262         this_ptr_conv.is_owned = false;
14263         LDKSignature val_ref;
14264         CHECK(*((uint32_t*)val) == 64);
14265         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14266         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
14267 }
14268
14269 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) {
14270         LDKThirtyTwoBytes channel_id_arg_ref;
14271         CHECK(*((uint32_t*)channel_id_arg) == 32);
14272         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14273         LDKSignature node_signature_arg_ref;
14274         CHECK(*((uint32_t*)node_signature_arg) == 64);
14275         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
14276         LDKSignature bitcoin_signature_arg_ref;
14277         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
14278         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
14279         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
14280         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14281         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14282         long ret_ref = (long)ret_var.inner;
14283         if (ret_var.is_owned) {
14284                 ret_ref |= 1;
14285         }
14286         return ret_ref;
14287 }
14288
14289 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
14290         LDKAnnouncementSignatures orig_conv;
14291         orig_conv.inner = (void*)(orig & (~1));
14292         orig_conv.is_owned = false;
14293         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
14294         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14295         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14296         long ret_ref = (long)ret_var.inner;
14297         if (ret_var.is_owned) {
14298                 ret_ref |= 1;
14299         }
14300         return ret_ref;
14301 }
14302
14303 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
14304         if ((this_ptr & 1) != 0) return;
14305         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
14306         FREE((void*)this_ptr);
14307         NetAddress_free(this_ptr_conv);
14308 }
14309
14310 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
14311         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
14312         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
14313         *ret_copy = NetAddress_clone(orig_conv);
14314         long ret_ref = (long)ret_copy;
14315         return ret_ref;
14316 }
14317
14318 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
14319         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
14320         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
14321         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14322         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14323         CVec_u8Z_free(ret_var);
14324         return ret_arr;
14325 }
14326
14327 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
14328         LDKu8slice ser_ref;
14329         ser_ref.datalen = *((uint32_t*)ser);
14330         ser_ref.data = (int8_t*)(ser + 4);
14331         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
14332         *ret_conv = Result_read(ser_ref);
14333         return (long)ret_conv;
14334 }
14335
14336 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
14337         LDKUnsignedNodeAnnouncement this_obj_conv;
14338         this_obj_conv.inner = (void*)(this_obj & (~1));
14339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14340         UnsignedNodeAnnouncement_free(this_obj_conv);
14341 }
14342
14343 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
14344         LDKUnsignedNodeAnnouncement this_ptr_conv;
14345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14346         this_ptr_conv.is_owned = false;
14347         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
14348         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14349         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14350         long ret_ref = (long)ret_var.inner;
14351         if (ret_var.is_owned) {
14352                 ret_ref |= 1;
14353         }
14354         return ret_ref;
14355 }
14356
14357 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
14358         LDKUnsignedNodeAnnouncement this_ptr_conv;
14359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14360         this_ptr_conv.is_owned = false;
14361         LDKNodeFeatures val_conv;
14362         val_conv.inner = (void*)(val & (~1));
14363         val_conv.is_owned = (val & 1) || (val == 0);
14364         val_conv = NodeFeatures_clone(&val_conv);
14365         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
14366 }
14367
14368 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
14369         LDKUnsignedNodeAnnouncement this_ptr_conv;
14370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14371         this_ptr_conv.is_owned = false;
14372         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
14373         return ret_val;
14374 }
14375
14376 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
14377         LDKUnsignedNodeAnnouncement this_ptr_conv;
14378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14379         this_ptr_conv.is_owned = false;
14380         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
14381 }
14382
14383 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
14384         LDKUnsignedNodeAnnouncement this_ptr_conv;
14385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14386         this_ptr_conv.is_owned = false;
14387         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14388         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
14389         return ret_arr;
14390 }
14391
14392 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
14393         LDKUnsignedNodeAnnouncement this_ptr_conv;
14394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14395         this_ptr_conv.is_owned = false;
14396         LDKPublicKey val_ref;
14397         CHECK(*((uint32_t*)val) == 33);
14398         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14399         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
14400 }
14401
14402 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
14403         LDKUnsignedNodeAnnouncement this_ptr_conv;
14404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14405         this_ptr_conv.is_owned = false;
14406         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
14407         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
14408         return ret_arr;
14409 }
14410
14411 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
14412         LDKUnsignedNodeAnnouncement this_ptr_conv;
14413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14414         this_ptr_conv.is_owned = false;
14415         LDKThreeBytes val_ref;
14416         CHECK(*((uint32_t*)val) == 3);
14417         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
14418         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
14419 }
14420
14421 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
14422         LDKUnsignedNodeAnnouncement this_ptr_conv;
14423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14424         this_ptr_conv.is_owned = false;
14425         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14426         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
14427         return ret_arr;
14428 }
14429
14430 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
14431         LDKUnsignedNodeAnnouncement this_ptr_conv;
14432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14433         this_ptr_conv.is_owned = false;
14434         LDKThirtyTwoBytes val_ref;
14435         CHECK(*((uint32_t*)val) == 32);
14436         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14437         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
14438 }
14439
14440 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
14441         LDKUnsignedNodeAnnouncement this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         LDKCVec_NetAddressZ val_constr;
14445         val_constr.datalen = *((uint32_t*)val);
14446         if (val_constr.datalen > 0)
14447                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14448         else
14449                 val_constr.data = NULL;
14450         uint32_t* val_vals = (uint32_t*)(val + 4);
14451         for (size_t m = 0; m < val_constr.datalen; m++) {
14452                 uint32_t val_conv_12 = val_vals[m];
14453                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
14454                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
14455                 val_constr.data[m] = val_conv_12_conv;
14456         }
14457         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
14458 }
14459
14460 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
14461         LDKUnsignedNodeAnnouncement orig_conv;
14462         orig_conv.inner = (void*)(orig & (~1));
14463         orig_conv.is_owned = false;
14464         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
14465         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14466         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14467         long ret_ref = (long)ret_var.inner;
14468         if (ret_var.is_owned) {
14469                 ret_ref |= 1;
14470         }
14471         return ret_ref;
14472 }
14473
14474 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
14475         LDKNodeAnnouncement this_obj_conv;
14476         this_obj_conv.inner = (void*)(this_obj & (~1));
14477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14478         NodeAnnouncement_free(this_obj_conv);
14479 }
14480
14481 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
14482         LDKNodeAnnouncement this_ptr_conv;
14483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14484         this_ptr_conv.is_owned = false;
14485         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14486         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
14487         return ret_arr;
14488 }
14489
14490 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
14491         LDKNodeAnnouncement this_ptr_conv;
14492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14493         this_ptr_conv.is_owned = false;
14494         LDKSignature val_ref;
14495         CHECK(*((uint32_t*)val) == 64);
14496         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14497         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
14498 }
14499
14500 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
14501         LDKNodeAnnouncement this_ptr_conv;
14502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14503         this_ptr_conv.is_owned = false;
14504         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
14505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14507         long ret_ref = (long)ret_var.inner;
14508         if (ret_var.is_owned) {
14509                 ret_ref |= 1;
14510         }
14511         return ret_ref;
14512 }
14513
14514 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
14515         LDKNodeAnnouncement this_ptr_conv;
14516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14517         this_ptr_conv.is_owned = false;
14518         LDKUnsignedNodeAnnouncement val_conv;
14519         val_conv.inner = (void*)(val & (~1));
14520         val_conv.is_owned = (val & 1) || (val == 0);
14521         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
14522         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
14523 }
14524
14525 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
14526         LDKSignature signature_arg_ref;
14527         CHECK(*((uint32_t*)signature_arg) == 64);
14528         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14529         LDKUnsignedNodeAnnouncement contents_arg_conv;
14530         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14531         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14532         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
14533         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
14534         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14535         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14536         long ret_ref = (long)ret_var.inner;
14537         if (ret_var.is_owned) {
14538                 ret_ref |= 1;
14539         }
14540         return ret_ref;
14541 }
14542
14543 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
14544         LDKNodeAnnouncement orig_conv;
14545         orig_conv.inner = (void*)(orig & (~1));
14546         orig_conv.is_owned = false;
14547         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
14548         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14549         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14550         long ret_ref = (long)ret_var.inner;
14551         if (ret_var.is_owned) {
14552                 ret_ref |= 1;
14553         }
14554         return ret_ref;
14555 }
14556
14557 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
14558         LDKUnsignedChannelAnnouncement this_obj_conv;
14559         this_obj_conv.inner = (void*)(this_obj & (~1));
14560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14561         UnsignedChannelAnnouncement_free(this_obj_conv);
14562 }
14563
14564 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
14565         LDKUnsignedChannelAnnouncement this_ptr_conv;
14566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14567         this_ptr_conv.is_owned = false;
14568         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
14569         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14570         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14571         long ret_ref = (long)ret_var.inner;
14572         if (ret_var.is_owned) {
14573                 ret_ref |= 1;
14574         }
14575         return ret_ref;
14576 }
14577
14578 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
14579         LDKUnsignedChannelAnnouncement this_ptr_conv;
14580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14581         this_ptr_conv.is_owned = false;
14582         LDKChannelFeatures val_conv;
14583         val_conv.inner = (void*)(val & (~1));
14584         val_conv.is_owned = (val & 1) || (val == 0);
14585         val_conv = ChannelFeatures_clone(&val_conv);
14586         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
14587 }
14588
14589 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
14590         LDKUnsignedChannelAnnouncement this_ptr_conv;
14591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14592         this_ptr_conv.is_owned = false;
14593         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14594         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
14595         return ret_arr;
14596 }
14597
14598 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14599         LDKUnsignedChannelAnnouncement this_ptr_conv;
14600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14601         this_ptr_conv.is_owned = false;
14602         LDKThirtyTwoBytes val_ref;
14603         CHECK(*((uint32_t*)val) == 32);
14604         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14605         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
14606 }
14607
14608 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
14609         LDKUnsignedChannelAnnouncement this_ptr_conv;
14610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14611         this_ptr_conv.is_owned = false;
14612         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
14613         return ret_val;
14614 }
14615
14616 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14617         LDKUnsignedChannelAnnouncement this_ptr_conv;
14618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14619         this_ptr_conv.is_owned = false;
14620         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
14621 }
14622
14623 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
14624         LDKUnsignedChannelAnnouncement this_ptr_conv;
14625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14626         this_ptr_conv.is_owned = false;
14627         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14628         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
14629         return ret_arr;
14630 }
14631
14632 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
14633         LDKUnsignedChannelAnnouncement this_ptr_conv;
14634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14635         this_ptr_conv.is_owned = false;
14636         LDKPublicKey val_ref;
14637         CHECK(*((uint32_t*)val) == 33);
14638         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14639         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
14640 }
14641
14642 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
14643         LDKUnsignedChannelAnnouncement this_ptr_conv;
14644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14645         this_ptr_conv.is_owned = false;
14646         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14647         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
14648         return ret_arr;
14649 }
14650
14651 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
14652         LDKUnsignedChannelAnnouncement this_ptr_conv;
14653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14654         this_ptr_conv.is_owned = false;
14655         LDKPublicKey val_ref;
14656         CHECK(*((uint32_t*)val) == 33);
14657         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14658         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
14659 }
14660
14661 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
14662         LDKUnsignedChannelAnnouncement this_ptr_conv;
14663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14664         this_ptr_conv.is_owned = false;
14665         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14666         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
14667         return ret_arr;
14668 }
14669
14670 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
14671         LDKUnsignedChannelAnnouncement this_ptr_conv;
14672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14673         this_ptr_conv.is_owned = false;
14674         LDKPublicKey val_ref;
14675         CHECK(*((uint32_t*)val) == 33);
14676         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14677         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
14678 }
14679
14680 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
14681         LDKUnsignedChannelAnnouncement this_ptr_conv;
14682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14683         this_ptr_conv.is_owned = false;
14684         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14685         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
14686         return ret_arr;
14687 }
14688
14689 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
14690         LDKUnsignedChannelAnnouncement this_ptr_conv;
14691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14692         this_ptr_conv.is_owned = false;
14693         LDKPublicKey val_ref;
14694         CHECK(*((uint32_t*)val) == 33);
14695         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14696         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
14697 }
14698
14699 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
14700         LDKUnsignedChannelAnnouncement orig_conv;
14701         orig_conv.inner = (void*)(orig & (~1));
14702         orig_conv.is_owned = false;
14703         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
14704         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14705         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14706         long ret_ref = (long)ret_var.inner;
14707         if (ret_var.is_owned) {
14708                 ret_ref |= 1;
14709         }
14710         return ret_ref;
14711 }
14712
14713 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
14714         LDKChannelAnnouncement this_obj_conv;
14715         this_obj_conv.inner = (void*)(this_obj & (~1));
14716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14717         ChannelAnnouncement_free(this_obj_conv);
14718 }
14719
14720 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
14721         LDKChannelAnnouncement this_ptr_conv;
14722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14723         this_ptr_conv.is_owned = false;
14724         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14725         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
14726         return ret_arr;
14727 }
14728
14729 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
14730         LDKChannelAnnouncement this_ptr_conv;
14731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14732         this_ptr_conv.is_owned = false;
14733         LDKSignature val_ref;
14734         CHECK(*((uint32_t*)val) == 64);
14735         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14736         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
14737 }
14738
14739 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
14740         LDKChannelAnnouncement this_ptr_conv;
14741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14742         this_ptr_conv.is_owned = false;
14743         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14744         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
14745         return ret_arr;
14746 }
14747
14748 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
14749         LDKChannelAnnouncement this_ptr_conv;
14750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14751         this_ptr_conv.is_owned = false;
14752         LDKSignature val_ref;
14753         CHECK(*((uint32_t*)val) == 64);
14754         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14755         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
14756 }
14757
14758 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
14759         LDKChannelAnnouncement this_ptr_conv;
14760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14761         this_ptr_conv.is_owned = false;
14762         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14763         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
14764         return ret_arr;
14765 }
14766
14767 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
14768         LDKChannelAnnouncement this_ptr_conv;
14769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14770         this_ptr_conv.is_owned = false;
14771         LDKSignature val_ref;
14772         CHECK(*((uint32_t*)val) == 64);
14773         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14774         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
14775 }
14776
14777 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
14778         LDKChannelAnnouncement this_ptr_conv;
14779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14780         this_ptr_conv.is_owned = false;
14781         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14782         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
14783         return ret_arr;
14784 }
14785
14786 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
14787         LDKChannelAnnouncement this_ptr_conv;
14788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14789         this_ptr_conv.is_owned = false;
14790         LDKSignature val_ref;
14791         CHECK(*((uint32_t*)val) == 64);
14792         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14793         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
14794 }
14795
14796 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
14797         LDKChannelAnnouncement this_ptr_conv;
14798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14799         this_ptr_conv.is_owned = false;
14800         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
14801         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14802         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14803         long ret_ref = (long)ret_var.inner;
14804         if (ret_var.is_owned) {
14805                 ret_ref |= 1;
14806         }
14807         return ret_ref;
14808 }
14809
14810 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
14811         LDKChannelAnnouncement this_ptr_conv;
14812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14813         this_ptr_conv.is_owned = false;
14814         LDKUnsignedChannelAnnouncement val_conv;
14815         val_conv.inner = (void*)(val & (~1));
14816         val_conv.is_owned = (val & 1) || (val == 0);
14817         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
14818         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
14819 }
14820
14821 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) {
14822         LDKSignature node_signature_1_arg_ref;
14823         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
14824         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
14825         LDKSignature node_signature_2_arg_ref;
14826         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
14827         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
14828         LDKSignature bitcoin_signature_1_arg_ref;
14829         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
14830         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
14831         LDKSignature bitcoin_signature_2_arg_ref;
14832         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
14833         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
14834         LDKUnsignedChannelAnnouncement contents_arg_conv;
14835         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14836         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14837         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
14838         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);
14839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14841         long ret_ref = (long)ret_var.inner;
14842         if (ret_var.is_owned) {
14843                 ret_ref |= 1;
14844         }
14845         return ret_ref;
14846 }
14847
14848 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
14849         LDKChannelAnnouncement orig_conv;
14850         orig_conv.inner = (void*)(orig & (~1));
14851         orig_conv.is_owned = false;
14852         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
14853         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14854         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14855         long ret_ref = (long)ret_var.inner;
14856         if (ret_var.is_owned) {
14857                 ret_ref |= 1;
14858         }
14859         return ret_ref;
14860 }
14861
14862 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
14863         LDKUnsignedChannelUpdate this_obj_conv;
14864         this_obj_conv.inner = (void*)(this_obj & (~1));
14865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14866         UnsignedChannelUpdate_free(this_obj_conv);
14867 }
14868
14869 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
14870         LDKUnsignedChannelUpdate this_ptr_conv;
14871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14872         this_ptr_conv.is_owned = false;
14873         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14874         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
14875         return ret_arr;
14876 }
14877
14878 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14879         LDKUnsignedChannelUpdate this_ptr_conv;
14880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14881         this_ptr_conv.is_owned = false;
14882         LDKThirtyTwoBytes val_ref;
14883         CHECK(*((uint32_t*)val) == 32);
14884         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14885         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
14886 }
14887
14888 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
14889         LDKUnsignedChannelUpdate this_ptr_conv;
14890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14891         this_ptr_conv.is_owned = false;
14892         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
14893         return ret_val;
14894 }
14895
14896 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14897         LDKUnsignedChannelUpdate this_ptr_conv;
14898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14899         this_ptr_conv.is_owned = false;
14900         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
14901 }
14902
14903 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
14904         LDKUnsignedChannelUpdate this_ptr_conv;
14905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14906         this_ptr_conv.is_owned = false;
14907         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
14908         return ret_val;
14909 }
14910
14911 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
14912         LDKUnsignedChannelUpdate this_ptr_conv;
14913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14914         this_ptr_conv.is_owned = false;
14915         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
14916 }
14917
14918 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
14919         LDKUnsignedChannelUpdate this_ptr_conv;
14920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14921         this_ptr_conv.is_owned = false;
14922         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
14923         return ret_val;
14924 }
14925
14926 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
14927         LDKUnsignedChannelUpdate this_ptr_conv;
14928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14929         this_ptr_conv.is_owned = false;
14930         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
14931 }
14932
14933 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
14934         LDKUnsignedChannelUpdate this_ptr_conv;
14935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14936         this_ptr_conv.is_owned = false;
14937         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
14938         return ret_val;
14939 }
14940
14941 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14942         LDKUnsignedChannelUpdate this_ptr_conv;
14943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14944         this_ptr_conv.is_owned = false;
14945         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
14946 }
14947
14948 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
14949         LDKUnsignedChannelUpdate this_ptr_conv;
14950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14951         this_ptr_conv.is_owned = false;
14952         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
14953         return ret_val;
14954 }
14955
14956 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14957         LDKUnsignedChannelUpdate this_ptr_conv;
14958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14959         this_ptr_conv.is_owned = false;
14960         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
14961 }
14962
14963 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
14964         LDKUnsignedChannelUpdate this_ptr_conv;
14965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14966         this_ptr_conv.is_owned = false;
14967         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
14968         return ret_val;
14969 }
14970
14971 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
14972         LDKUnsignedChannelUpdate this_ptr_conv;
14973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14974         this_ptr_conv.is_owned = false;
14975         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
14976 }
14977
14978 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
14979         LDKUnsignedChannelUpdate this_ptr_conv;
14980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14981         this_ptr_conv.is_owned = false;
14982         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
14983         return ret_val;
14984 }
14985
14986 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14987         LDKUnsignedChannelUpdate this_ptr_conv;
14988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14989         this_ptr_conv.is_owned = false;
14990         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
14991 }
14992
14993 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
14994         LDKUnsignedChannelUpdate orig_conv;
14995         orig_conv.inner = (void*)(orig & (~1));
14996         orig_conv.is_owned = false;
14997         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
14998         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14999         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15000         long ret_ref = (long)ret_var.inner;
15001         if (ret_var.is_owned) {
15002                 ret_ref |= 1;
15003         }
15004         return ret_ref;
15005 }
15006
15007 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
15008         LDKChannelUpdate this_obj_conv;
15009         this_obj_conv.inner = (void*)(this_obj & (~1));
15010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15011         ChannelUpdate_free(this_obj_conv);
15012 }
15013
15014 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
15015         LDKChannelUpdate this_ptr_conv;
15016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15017         this_ptr_conv.is_owned = false;
15018         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15019         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
15020         return ret_arr;
15021 }
15022
15023 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
15024         LDKChannelUpdate this_ptr_conv;
15025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15026         this_ptr_conv.is_owned = false;
15027         LDKSignature val_ref;
15028         CHECK(*((uint32_t*)val) == 64);
15029         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15030         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
15031 }
15032
15033 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
15034         LDKChannelUpdate this_ptr_conv;
15035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15036         this_ptr_conv.is_owned = false;
15037         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
15038         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15039         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15040         long ret_ref = (long)ret_var.inner;
15041         if (ret_var.is_owned) {
15042                 ret_ref |= 1;
15043         }
15044         return ret_ref;
15045 }
15046
15047 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
15048         LDKChannelUpdate this_ptr_conv;
15049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15050         this_ptr_conv.is_owned = false;
15051         LDKUnsignedChannelUpdate val_conv;
15052         val_conv.inner = (void*)(val & (~1));
15053         val_conv.is_owned = (val & 1) || (val == 0);
15054         val_conv = UnsignedChannelUpdate_clone(&val_conv);
15055         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
15056 }
15057
15058 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
15059         LDKSignature signature_arg_ref;
15060         CHECK(*((uint32_t*)signature_arg) == 64);
15061         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15062         LDKUnsignedChannelUpdate contents_arg_conv;
15063         contents_arg_conv.inner = (void*)(contents_arg & (~1));
15064         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
15065         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
15066         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
15067         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15068         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15069         long ret_ref = (long)ret_var.inner;
15070         if (ret_var.is_owned) {
15071                 ret_ref |= 1;
15072         }
15073         return ret_ref;
15074 }
15075
15076 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
15077         LDKChannelUpdate orig_conv;
15078         orig_conv.inner = (void*)(orig & (~1));
15079         orig_conv.is_owned = false;
15080         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
15081         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15082         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15083         long ret_ref = (long)ret_var.inner;
15084         if (ret_var.is_owned) {
15085                 ret_ref |= 1;
15086         }
15087         return ret_ref;
15088 }
15089
15090 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
15091         LDKQueryChannelRange this_obj_conv;
15092         this_obj_conv.inner = (void*)(this_obj & (~1));
15093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15094         QueryChannelRange_free(this_obj_conv);
15095 }
15096
15097 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
15098         LDKQueryChannelRange this_ptr_conv;
15099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15100         this_ptr_conv.is_owned = false;
15101         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15102         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
15103         return ret_arr;
15104 }
15105
15106 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15107         LDKQueryChannelRange this_ptr_conv;
15108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15109         this_ptr_conv.is_owned = false;
15110         LDKThirtyTwoBytes val_ref;
15111         CHECK(*((uint32_t*)val) == 32);
15112         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15113         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15114 }
15115
15116 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
15117         LDKQueryChannelRange this_ptr_conv;
15118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15119         this_ptr_conv.is_owned = false;
15120         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
15121         return ret_val;
15122 }
15123
15124 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
15125         LDKQueryChannelRange this_ptr_conv;
15126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15127         this_ptr_conv.is_owned = false;
15128         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
15129 }
15130
15131 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
15132         LDKQueryChannelRange this_ptr_conv;
15133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15134         this_ptr_conv.is_owned = false;
15135         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
15136         return ret_val;
15137 }
15138
15139 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
15140         LDKQueryChannelRange this_ptr_conv;
15141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15142         this_ptr_conv.is_owned = false;
15143         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15144 }
15145
15146 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
15147         LDKThirtyTwoBytes chain_hash_arg_ref;
15148         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15149         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15150         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
15151         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15152         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15153         long ret_ref = (long)ret_var.inner;
15154         if (ret_var.is_owned) {
15155                 ret_ref |= 1;
15156         }
15157         return ret_ref;
15158 }
15159
15160 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
15161         LDKQueryChannelRange orig_conv;
15162         orig_conv.inner = (void*)(orig & (~1));
15163         orig_conv.is_owned = false;
15164         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
15165         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15166         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15167         long ret_ref = (long)ret_var.inner;
15168         if (ret_var.is_owned) {
15169                 ret_ref |= 1;
15170         }
15171         return ret_ref;
15172 }
15173
15174 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
15175         LDKReplyChannelRange this_obj_conv;
15176         this_obj_conv.inner = (void*)(this_obj & (~1));
15177         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15178         ReplyChannelRange_free(this_obj_conv);
15179 }
15180
15181 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
15182         LDKReplyChannelRange this_ptr_conv;
15183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15184         this_ptr_conv.is_owned = false;
15185         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15186         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
15187         return ret_arr;
15188 }
15189
15190 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15191         LDKReplyChannelRange this_ptr_conv;
15192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15193         this_ptr_conv.is_owned = false;
15194         LDKThirtyTwoBytes val_ref;
15195         CHECK(*((uint32_t*)val) == 32);
15196         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15197         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
15198 }
15199
15200 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
15201         LDKReplyChannelRange this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
15205         return ret_val;
15206 }
15207
15208 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
15209         LDKReplyChannelRange this_ptr_conv;
15210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15211         this_ptr_conv.is_owned = false;
15212         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
15213 }
15214
15215 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
15216         LDKReplyChannelRange this_ptr_conv;
15217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15218         this_ptr_conv.is_owned = false;
15219         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
15220         return ret_val;
15221 }
15222
15223 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
15224         LDKReplyChannelRange this_ptr_conv;
15225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15226         this_ptr_conv.is_owned = false;
15227         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
15228 }
15229
15230 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
15231         LDKReplyChannelRange this_ptr_conv;
15232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15233         this_ptr_conv.is_owned = false;
15234         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
15235         return ret_val;
15236 }
15237
15238 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
15239         LDKReplyChannelRange this_ptr_conv;
15240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15241         this_ptr_conv.is_owned = false;
15242         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
15243 }
15244
15245 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
15246         LDKReplyChannelRange this_ptr_conv;
15247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15248         this_ptr_conv.is_owned = false;
15249         LDKCVec_u64Z val_constr;
15250         val_constr.datalen = *((uint32_t*)val);
15251         if (val_constr.datalen > 0)
15252                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15253         else
15254                 val_constr.data = NULL;
15255         int64_t* val_vals = (int64_t*)(val + 4);
15256         for (size_t i = 0; i < val_constr.datalen; i++) {
15257                 int64_t val_conv_8 = val_vals[i];
15258                 val_constr.data[i] = val_conv_8;
15259         }
15260         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
15261 }
15262
15263 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) {
15264         LDKThirtyTwoBytes chain_hash_arg_ref;
15265         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15266         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15267         LDKCVec_u64Z short_channel_ids_arg_constr;
15268         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
15269         if (short_channel_ids_arg_constr.datalen > 0)
15270                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15271         else
15272                 short_channel_ids_arg_constr.data = NULL;
15273         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
15274         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
15275                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
15276                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
15277         }
15278         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
15279         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15280         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15281         long ret_ref = (long)ret_var.inner;
15282         if (ret_var.is_owned) {
15283                 ret_ref |= 1;
15284         }
15285         return ret_ref;
15286 }
15287
15288 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
15289         LDKReplyChannelRange orig_conv;
15290         orig_conv.inner = (void*)(orig & (~1));
15291         orig_conv.is_owned = false;
15292         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
15293         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15294         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15295         long ret_ref = (long)ret_var.inner;
15296         if (ret_var.is_owned) {
15297                 ret_ref |= 1;
15298         }
15299         return ret_ref;
15300 }
15301
15302 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
15303         LDKQueryShortChannelIds this_obj_conv;
15304         this_obj_conv.inner = (void*)(this_obj & (~1));
15305         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15306         QueryShortChannelIds_free(this_obj_conv);
15307 }
15308
15309 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
15310         LDKQueryShortChannelIds this_ptr_conv;
15311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15312         this_ptr_conv.is_owned = false;
15313         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15314         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
15315         return ret_arr;
15316 }
15317
15318 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15319         LDKQueryShortChannelIds this_ptr_conv;
15320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15321         this_ptr_conv.is_owned = false;
15322         LDKThirtyTwoBytes val_ref;
15323         CHECK(*((uint32_t*)val) == 32);
15324         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15325         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
15326 }
15327
15328 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
15329         LDKQueryShortChannelIds this_ptr_conv;
15330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15331         this_ptr_conv.is_owned = false;
15332         LDKCVec_u64Z val_constr;
15333         val_constr.datalen = *((uint32_t*)val);
15334         if (val_constr.datalen > 0)
15335                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15336         else
15337                 val_constr.data = NULL;
15338         int64_t* val_vals = (int64_t*)(val + 4);
15339         for (size_t i = 0; i < val_constr.datalen; i++) {
15340                 int64_t val_conv_8 = val_vals[i];
15341                 val_constr.data[i] = val_conv_8;
15342         }
15343         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
15344 }
15345
15346 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
15347         LDKThirtyTwoBytes chain_hash_arg_ref;
15348         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15349         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15350         LDKCVec_u64Z short_channel_ids_arg_constr;
15351         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
15352         if (short_channel_ids_arg_constr.datalen > 0)
15353                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15354         else
15355                 short_channel_ids_arg_constr.data = NULL;
15356         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
15357         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
15358                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
15359                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
15360         }
15361         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
15362         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15363         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15364         long ret_ref = (long)ret_var.inner;
15365         if (ret_var.is_owned) {
15366                 ret_ref |= 1;
15367         }
15368         return ret_ref;
15369 }
15370
15371 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
15372         LDKQueryShortChannelIds orig_conv;
15373         orig_conv.inner = (void*)(orig & (~1));
15374         orig_conv.is_owned = false;
15375         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
15376         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15377         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15378         long ret_ref = (long)ret_var.inner;
15379         if (ret_var.is_owned) {
15380                 ret_ref |= 1;
15381         }
15382         return ret_ref;
15383 }
15384
15385 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
15386         LDKReplyShortChannelIdsEnd this_obj_conv;
15387         this_obj_conv.inner = (void*)(this_obj & (~1));
15388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15389         ReplyShortChannelIdsEnd_free(this_obj_conv);
15390 }
15391
15392 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
15393         LDKReplyShortChannelIdsEnd this_ptr_conv;
15394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15395         this_ptr_conv.is_owned = false;
15396         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15397         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
15398         return ret_arr;
15399 }
15400
15401 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15402         LDKReplyShortChannelIdsEnd this_ptr_conv;
15403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404         this_ptr_conv.is_owned = false;
15405         LDKThirtyTwoBytes val_ref;
15406         CHECK(*((uint32_t*)val) == 32);
15407         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15408         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
15409 }
15410
15411 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
15412         LDKReplyShortChannelIdsEnd this_ptr_conv;
15413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15414         this_ptr_conv.is_owned = false;
15415         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
15416         return ret_val;
15417 }
15418
15419 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
15420         LDKReplyShortChannelIdsEnd this_ptr_conv;
15421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15422         this_ptr_conv.is_owned = false;
15423         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
15424 }
15425
15426 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
15427         LDKThirtyTwoBytes chain_hash_arg_ref;
15428         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15429         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15430         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
15431         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15432         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15433         long ret_ref = (long)ret_var.inner;
15434         if (ret_var.is_owned) {
15435                 ret_ref |= 1;
15436         }
15437         return ret_ref;
15438 }
15439
15440 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
15441         LDKReplyShortChannelIdsEnd orig_conv;
15442         orig_conv.inner = (void*)(orig & (~1));
15443         orig_conv.is_owned = false;
15444         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
15445         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15446         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15447         long ret_ref = (long)ret_var.inner;
15448         if (ret_var.is_owned) {
15449                 ret_ref |= 1;
15450         }
15451         return ret_ref;
15452 }
15453
15454 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
15455         LDKGossipTimestampFilter this_obj_conv;
15456         this_obj_conv.inner = (void*)(this_obj & (~1));
15457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15458         GossipTimestampFilter_free(this_obj_conv);
15459 }
15460
15461 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
15462         LDKGossipTimestampFilter this_ptr_conv;
15463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15464         this_ptr_conv.is_owned = false;
15465         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15466         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
15467         return ret_arr;
15468 }
15469
15470 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
15471         LDKGossipTimestampFilter this_ptr_conv;
15472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15473         this_ptr_conv.is_owned = false;
15474         LDKThirtyTwoBytes val_ref;
15475         CHECK(*((uint32_t*)val) == 32);
15476         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15477         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
15478 }
15479
15480 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
15481         LDKGossipTimestampFilter this_ptr_conv;
15482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15483         this_ptr_conv.is_owned = false;
15484         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
15485         return ret_val;
15486 }
15487
15488 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
15489         LDKGossipTimestampFilter this_ptr_conv;
15490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15491         this_ptr_conv.is_owned = false;
15492         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
15493 }
15494
15495 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
15496         LDKGossipTimestampFilter this_ptr_conv;
15497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15498         this_ptr_conv.is_owned = false;
15499         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
15500         return ret_val;
15501 }
15502
15503 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
15504         LDKGossipTimestampFilter this_ptr_conv;
15505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15506         this_ptr_conv.is_owned = false;
15507         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
15508 }
15509
15510 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
15511         LDKThirtyTwoBytes chain_hash_arg_ref;
15512         CHECK(*((uint32_t*)chain_hash_arg) == 32);
15513         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
15514         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
15515         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15516         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15517         long ret_ref = (long)ret_var.inner;
15518         if (ret_var.is_owned) {
15519                 ret_ref |= 1;
15520         }
15521         return ret_ref;
15522 }
15523
15524 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
15525         LDKGossipTimestampFilter orig_conv;
15526         orig_conv.inner = (void*)(orig & (~1));
15527         orig_conv.is_owned = false;
15528         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
15529         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15530         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15531         long ret_ref = (long)ret_var.inner;
15532         if (ret_var.is_owned) {
15533                 ret_ref |= 1;
15534         }
15535         return ret_ref;
15536 }
15537
15538 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
15539         if ((this_ptr & 1) != 0) return;
15540         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
15541         FREE((void*)this_ptr);
15542         ErrorAction_free(this_ptr_conv);
15543 }
15544
15545 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
15546         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
15547         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15548         *ret_copy = ErrorAction_clone(orig_conv);
15549         long ret_ref = (long)ret_copy;
15550         return ret_ref;
15551 }
15552
15553 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
15554         LDKLightningError this_obj_conv;
15555         this_obj_conv.inner = (void*)(this_obj & (~1));
15556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15557         LightningError_free(this_obj_conv);
15558 }
15559
15560 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
15561         LDKLightningError this_ptr_conv;
15562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15563         this_ptr_conv.is_owned = false;
15564         LDKStr _str = LightningError_get_err(&this_ptr_conv);
15565         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
15566         return _conv;
15567 }
15568
15569 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
15570         LDKLightningError this_ptr_conv;
15571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15572         this_ptr_conv.is_owned = false;
15573         LDKCVec_u8Z val_ref;
15574         val_ref.datalen = *((uint32_t*)val);
15575         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15576         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
15577         LightningError_set_err(&this_ptr_conv, val_ref);
15578 }
15579
15580 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
15581         LDKLightningError this_ptr_conv;
15582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15583         this_ptr_conv.is_owned = false;
15584         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
15585         *ret_copy = LightningError_get_action(&this_ptr_conv);
15586         long ret_ref = (long)ret_copy;
15587         return ret_ref;
15588 }
15589
15590 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
15591         LDKLightningError this_ptr_conv;
15592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15593         this_ptr_conv.is_owned = false;
15594         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
15595         FREE((void*)val);
15596         LightningError_set_action(&this_ptr_conv, val_conv);
15597 }
15598
15599 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
15600         LDKCVec_u8Z err_arg_ref;
15601         err_arg_ref.datalen = *((uint32_t*)err_arg);
15602         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15603         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
15604         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
15605         FREE((void*)action_arg);
15606         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
15607         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15608         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15609         long ret_ref = (long)ret_var.inner;
15610         if (ret_var.is_owned) {
15611                 ret_ref |= 1;
15612         }
15613         return ret_ref;
15614 }
15615
15616 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
15617         LDKLightningError orig_conv;
15618         orig_conv.inner = (void*)(orig & (~1));
15619         orig_conv.is_owned = false;
15620         LDKLightningError ret_var = LightningError_clone(&orig_conv);
15621         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15622         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15623         long ret_ref = (long)ret_var.inner;
15624         if (ret_var.is_owned) {
15625                 ret_ref |= 1;
15626         }
15627         return ret_ref;
15628 }
15629
15630 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
15631         LDKCommitmentUpdate this_obj_conv;
15632         this_obj_conv.inner = (void*)(this_obj & (~1));
15633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15634         CommitmentUpdate_free(this_obj_conv);
15635 }
15636
15637 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
15638         LDKCommitmentUpdate this_ptr_conv;
15639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15640         this_ptr_conv.is_owned = false;
15641         LDKCVec_UpdateAddHTLCZ val_constr;
15642         val_constr.datalen = *((uint32_t*)val);
15643         if (val_constr.datalen > 0)
15644                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15645         else
15646                 val_constr.data = NULL;
15647         uint32_t* val_vals = (uint32_t*)(val + 4);
15648         for (size_t p = 0; p < val_constr.datalen; p++) {
15649                 uint32_t val_conv_15 = val_vals[p];
15650                 LDKUpdateAddHTLC val_conv_15_conv;
15651                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
15652                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
15653                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
15654                 val_constr.data[p] = val_conv_15_conv;
15655         }
15656         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
15657 }
15658
15659 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
15660         LDKCommitmentUpdate this_ptr_conv;
15661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15662         this_ptr_conv.is_owned = false;
15663         LDKCVec_UpdateFulfillHTLCZ val_constr;
15664         val_constr.datalen = *((uint32_t*)val);
15665         if (val_constr.datalen > 0)
15666                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15667         else
15668                 val_constr.data = NULL;
15669         uint32_t* val_vals = (uint32_t*)(val + 4);
15670         for (size_t t = 0; t < val_constr.datalen; t++) {
15671                 uint32_t val_conv_19 = val_vals[t];
15672                 LDKUpdateFulfillHTLC val_conv_19_conv;
15673                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
15674                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
15675                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
15676                 val_constr.data[t] = val_conv_19_conv;
15677         }
15678         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
15679 }
15680
15681 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
15682         LDKCommitmentUpdate this_ptr_conv;
15683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15684         this_ptr_conv.is_owned = false;
15685         LDKCVec_UpdateFailHTLCZ val_constr;
15686         val_constr.datalen = *((uint32_t*)val);
15687         if (val_constr.datalen > 0)
15688                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15689         else
15690                 val_constr.data = NULL;
15691         uint32_t* val_vals = (uint32_t*)(val + 4);
15692         for (size_t q = 0; q < val_constr.datalen; q++) {
15693                 uint32_t val_conv_16 = val_vals[q];
15694                 LDKUpdateFailHTLC val_conv_16_conv;
15695                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
15696                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
15697                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
15698                 val_constr.data[q] = val_conv_16_conv;
15699         }
15700         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
15701 }
15702
15703 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
15704         LDKCommitmentUpdate this_ptr_conv;
15705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15706         this_ptr_conv.is_owned = false;
15707         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
15708         val_constr.datalen = *((uint32_t*)val);
15709         if (val_constr.datalen > 0)
15710                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15711         else
15712                 val_constr.data = NULL;
15713         uint32_t* val_vals = (uint32_t*)(val + 4);
15714         for (size_t z = 0; z < val_constr.datalen; z++) {
15715                 uint32_t val_conv_25 = val_vals[z];
15716                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
15717                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
15718                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
15719                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
15720                 val_constr.data[z] = val_conv_25_conv;
15721         }
15722         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
15723 }
15724
15725 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
15726         LDKCommitmentUpdate this_ptr_conv;
15727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15728         this_ptr_conv.is_owned = false;
15729         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
15730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15732         long ret_ref = (long)ret_var.inner;
15733         if (ret_var.is_owned) {
15734                 ret_ref |= 1;
15735         }
15736         return ret_ref;
15737 }
15738
15739 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
15740         LDKCommitmentUpdate this_ptr_conv;
15741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15742         this_ptr_conv.is_owned = false;
15743         LDKUpdateFee val_conv;
15744         val_conv.inner = (void*)(val & (~1));
15745         val_conv.is_owned = (val & 1) || (val == 0);
15746         val_conv = UpdateFee_clone(&val_conv);
15747         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
15748 }
15749
15750 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
15751         LDKCommitmentUpdate this_ptr_conv;
15752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15753         this_ptr_conv.is_owned = false;
15754         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
15755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15757         long ret_ref = (long)ret_var.inner;
15758         if (ret_var.is_owned) {
15759                 ret_ref |= 1;
15760         }
15761         return ret_ref;
15762 }
15763
15764 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
15765         LDKCommitmentUpdate this_ptr_conv;
15766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15767         this_ptr_conv.is_owned = false;
15768         LDKCommitmentSigned val_conv;
15769         val_conv.inner = (void*)(val & (~1));
15770         val_conv.is_owned = (val & 1) || (val == 0);
15771         val_conv = CommitmentSigned_clone(&val_conv);
15772         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
15773 }
15774
15775 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) {
15776         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
15777         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
15778         if (update_add_htlcs_arg_constr.datalen > 0)
15779                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
15780         else
15781                 update_add_htlcs_arg_constr.data = NULL;
15782         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
15783         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
15784                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
15785                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
15786                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
15787                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
15788                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
15789                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
15790         }
15791         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
15792         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
15793         if (update_fulfill_htlcs_arg_constr.datalen > 0)
15794                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
15795         else
15796                 update_fulfill_htlcs_arg_constr.data = NULL;
15797         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
15798         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
15799                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
15800                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
15801                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
15802                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
15803                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
15804                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
15805         }
15806         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
15807         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
15808         if (update_fail_htlcs_arg_constr.datalen > 0)
15809                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15810         else
15811                 update_fail_htlcs_arg_constr.data = NULL;
15812         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
15813         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
15814                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
15815                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
15816                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
15817                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
15818                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
15819                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
15820         }
15821         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
15822         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
15823         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
15824                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15825         else
15826                 update_fail_malformed_htlcs_arg_constr.data = NULL;
15827         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
15828         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
15829                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
15830                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
15831                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
15832                 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);
15833                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
15834                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
15835         }
15836         LDKUpdateFee update_fee_arg_conv;
15837         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
15838         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
15839         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
15840         LDKCommitmentSigned commitment_signed_arg_conv;
15841         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
15842         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
15843         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
15844         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);
15845         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15846         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15847         long ret_ref = (long)ret_var.inner;
15848         if (ret_var.is_owned) {
15849                 ret_ref |= 1;
15850         }
15851         return ret_ref;
15852 }
15853
15854 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
15855         LDKCommitmentUpdate orig_conv;
15856         orig_conv.inner = (void*)(orig & (~1));
15857         orig_conv.is_owned = false;
15858         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
15859         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15860         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15861         long ret_ref = (long)ret_var.inner;
15862         if (ret_var.is_owned) {
15863                 ret_ref |= 1;
15864         }
15865         return ret_ref;
15866 }
15867
15868 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
15869         if ((this_ptr & 1) != 0) return;
15870         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
15871         FREE((void*)this_ptr);
15872         HTLCFailChannelUpdate_free(this_ptr_conv);
15873 }
15874
15875 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
15876         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
15877         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
15878         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
15879         long ret_ref = (long)ret_copy;
15880         return ret_ref;
15881 }
15882
15883 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
15884         if ((this_ptr & 1) != 0) return;
15885         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
15886         FREE((void*)this_ptr);
15887         ChannelMessageHandler_free(this_ptr_conv);
15888 }
15889
15890 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
15891         if ((this_ptr & 1) != 0) return;
15892         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
15893         FREE((void*)this_ptr);
15894         RoutingMessageHandler_free(this_ptr_conv);
15895 }
15896
15897 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
15898         LDKAcceptChannel obj_conv;
15899         obj_conv.inner = (void*)(obj & (~1));
15900         obj_conv.is_owned = false;
15901         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
15902         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15903         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15904         CVec_u8Z_free(ret_var);
15905         return ret_arr;
15906 }
15907
15908 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
15909         LDKu8slice ser_ref;
15910         ser_ref.datalen = *((uint32_t*)ser);
15911         ser_ref.data = (int8_t*)(ser + 4);
15912         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15913         *ret_conv = AcceptChannel_read(ser_ref);
15914         return (long)ret_conv;
15915 }
15916
15917 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
15918         LDKAnnouncementSignatures obj_conv;
15919         obj_conv.inner = (void*)(obj & (~1));
15920         obj_conv.is_owned = false;
15921         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
15922         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15923         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15924         CVec_u8Z_free(ret_var);
15925         return ret_arr;
15926 }
15927
15928 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
15929         LDKu8slice ser_ref;
15930         ser_ref.datalen = *((uint32_t*)ser);
15931         ser_ref.data = (int8_t*)(ser + 4);
15932         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15933         *ret_conv = AnnouncementSignatures_read(ser_ref);
15934         return (long)ret_conv;
15935 }
15936
15937 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
15938         LDKChannelReestablish obj_conv;
15939         obj_conv.inner = (void*)(obj & (~1));
15940         obj_conv.is_owned = false;
15941         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
15942         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15943         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15944         CVec_u8Z_free(ret_var);
15945         return ret_arr;
15946 }
15947
15948 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
15949         LDKu8slice ser_ref;
15950         ser_ref.datalen = *((uint32_t*)ser);
15951         ser_ref.data = (int8_t*)(ser + 4);
15952         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15953         *ret_conv = ChannelReestablish_read(ser_ref);
15954         return (long)ret_conv;
15955 }
15956
15957 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
15958         LDKClosingSigned obj_conv;
15959         obj_conv.inner = (void*)(obj & (~1));
15960         obj_conv.is_owned = false;
15961         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
15962         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15963         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15964         CVec_u8Z_free(ret_var);
15965         return ret_arr;
15966 }
15967
15968 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
15969         LDKu8slice ser_ref;
15970         ser_ref.datalen = *((uint32_t*)ser);
15971         ser_ref.data = (int8_t*)(ser + 4);
15972         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15973         *ret_conv = ClosingSigned_read(ser_ref);
15974         return (long)ret_conv;
15975 }
15976
15977 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
15978         LDKCommitmentSigned obj_conv;
15979         obj_conv.inner = (void*)(obj & (~1));
15980         obj_conv.is_owned = false;
15981         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
15982         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15983         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15984         CVec_u8Z_free(ret_var);
15985         return ret_arr;
15986 }
15987
15988 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
15989         LDKu8slice ser_ref;
15990         ser_ref.datalen = *((uint32_t*)ser);
15991         ser_ref.data = (int8_t*)(ser + 4);
15992         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15993         *ret_conv = CommitmentSigned_read(ser_ref);
15994         return (long)ret_conv;
15995 }
15996
15997 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
15998         LDKFundingCreated obj_conv;
15999         obj_conv.inner = (void*)(obj & (~1));
16000         obj_conv.is_owned = false;
16001         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
16002         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16003         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16004         CVec_u8Z_free(ret_var);
16005         return ret_arr;
16006 }
16007
16008 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
16009         LDKu8slice ser_ref;
16010         ser_ref.datalen = *((uint32_t*)ser);
16011         ser_ref.data = (int8_t*)(ser + 4);
16012         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
16013         *ret_conv = FundingCreated_read(ser_ref);
16014         return (long)ret_conv;
16015 }
16016
16017 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
16018         LDKFundingSigned obj_conv;
16019         obj_conv.inner = (void*)(obj & (~1));
16020         obj_conv.is_owned = false;
16021         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
16022         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16023         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16024         CVec_u8Z_free(ret_var);
16025         return ret_arr;
16026 }
16027
16028 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
16029         LDKu8slice ser_ref;
16030         ser_ref.datalen = *((uint32_t*)ser);
16031         ser_ref.data = (int8_t*)(ser + 4);
16032         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
16033         *ret_conv = FundingSigned_read(ser_ref);
16034         return (long)ret_conv;
16035 }
16036
16037 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
16038         LDKFundingLocked obj_conv;
16039         obj_conv.inner = (void*)(obj & (~1));
16040         obj_conv.is_owned = false;
16041         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
16042         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16043         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16044         CVec_u8Z_free(ret_var);
16045         return ret_arr;
16046 }
16047
16048 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
16049         LDKu8slice ser_ref;
16050         ser_ref.datalen = *((uint32_t*)ser);
16051         ser_ref.data = (int8_t*)(ser + 4);
16052         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
16053         *ret_conv = FundingLocked_read(ser_ref);
16054         return (long)ret_conv;
16055 }
16056
16057 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
16058         LDKInit obj_conv;
16059         obj_conv.inner = (void*)(obj & (~1));
16060         obj_conv.is_owned = false;
16061         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
16062         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16063         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16064         CVec_u8Z_free(ret_var);
16065         return ret_arr;
16066 }
16067
16068 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
16069         LDKu8slice ser_ref;
16070         ser_ref.datalen = *((uint32_t*)ser);
16071         ser_ref.data = (int8_t*)(ser + 4);
16072         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
16073         *ret_conv = Init_read(ser_ref);
16074         return (long)ret_conv;
16075 }
16076
16077 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
16078         LDKOpenChannel obj_conv;
16079         obj_conv.inner = (void*)(obj & (~1));
16080         obj_conv.is_owned = false;
16081         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
16082         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16083         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16084         CVec_u8Z_free(ret_var);
16085         return ret_arr;
16086 }
16087
16088 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
16089         LDKu8slice ser_ref;
16090         ser_ref.datalen = *((uint32_t*)ser);
16091         ser_ref.data = (int8_t*)(ser + 4);
16092         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
16093         *ret_conv = OpenChannel_read(ser_ref);
16094         return (long)ret_conv;
16095 }
16096
16097 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
16098         LDKRevokeAndACK obj_conv;
16099         obj_conv.inner = (void*)(obj & (~1));
16100         obj_conv.is_owned = false;
16101         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
16102         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16103         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16104         CVec_u8Z_free(ret_var);
16105         return ret_arr;
16106 }
16107
16108 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
16109         LDKu8slice ser_ref;
16110         ser_ref.datalen = *((uint32_t*)ser);
16111         ser_ref.data = (int8_t*)(ser + 4);
16112         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
16113         *ret_conv = RevokeAndACK_read(ser_ref);
16114         return (long)ret_conv;
16115 }
16116
16117 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
16118         LDKShutdown obj_conv;
16119         obj_conv.inner = (void*)(obj & (~1));
16120         obj_conv.is_owned = false;
16121         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
16122         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16123         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16124         CVec_u8Z_free(ret_var);
16125         return ret_arr;
16126 }
16127
16128 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
16129         LDKu8slice ser_ref;
16130         ser_ref.datalen = *((uint32_t*)ser);
16131         ser_ref.data = (int8_t*)(ser + 4);
16132         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
16133         *ret_conv = Shutdown_read(ser_ref);
16134         return (long)ret_conv;
16135 }
16136
16137 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
16138         LDKUpdateFailHTLC obj_conv;
16139         obj_conv.inner = (void*)(obj & (~1));
16140         obj_conv.is_owned = false;
16141         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
16142         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16143         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16144         CVec_u8Z_free(ret_var);
16145         return ret_arr;
16146 }
16147
16148 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
16149         LDKu8slice ser_ref;
16150         ser_ref.datalen = *((uint32_t*)ser);
16151         ser_ref.data = (int8_t*)(ser + 4);
16152         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
16153         *ret_conv = UpdateFailHTLC_read(ser_ref);
16154         return (long)ret_conv;
16155 }
16156
16157 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
16158         LDKUpdateFailMalformedHTLC obj_conv;
16159         obj_conv.inner = (void*)(obj & (~1));
16160         obj_conv.is_owned = false;
16161         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
16162         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16163         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16164         CVec_u8Z_free(ret_var);
16165         return ret_arr;
16166 }
16167
16168 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
16169         LDKu8slice ser_ref;
16170         ser_ref.datalen = *((uint32_t*)ser);
16171         ser_ref.data = (int8_t*)(ser + 4);
16172         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
16173         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
16174         return (long)ret_conv;
16175 }
16176
16177 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
16178         LDKUpdateFee obj_conv;
16179         obj_conv.inner = (void*)(obj & (~1));
16180         obj_conv.is_owned = false;
16181         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
16182         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16183         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16184         CVec_u8Z_free(ret_var);
16185         return ret_arr;
16186 }
16187
16188 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
16189         LDKu8slice ser_ref;
16190         ser_ref.datalen = *((uint32_t*)ser);
16191         ser_ref.data = (int8_t*)(ser + 4);
16192         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
16193         *ret_conv = UpdateFee_read(ser_ref);
16194         return (long)ret_conv;
16195 }
16196
16197 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
16198         LDKUpdateFulfillHTLC obj_conv;
16199         obj_conv.inner = (void*)(obj & (~1));
16200         obj_conv.is_owned = false;
16201         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
16202         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16203         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16204         CVec_u8Z_free(ret_var);
16205         return ret_arr;
16206 }
16207
16208 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
16209         LDKu8slice ser_ref;
16210         ser_ref.datalen = *((uint32_t*)ser);
16211         ser_ref.data = (int8_t*)(ser + 4);
16212         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
16213         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
16214         return (long)ret_conv;
16215 }
16216
16217 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
16218         LDKUpdateAddHTLC obj_conv;
16219         obj_conv.inner = (void*)(obj & (~1));
16220         obj_conv.is_owned = false;
16221         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
16222         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16223         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16224         CVec_u8Z_free(ret_var);
16225         return ret_arr;
16226 }
16227
16228 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
16229         LDKu8slice ser_ref;
16230         ser_ref.datalen = *((uint32_t*)ser);
16231         ser_ref.data = (int8_t*)(ser + 4);
16232         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
16233         *ret_conv = UpdateAddHTLC_read(ser_ref);
16234         return (long)ret_conv;
16235 }
16236
16237 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
16238         LDKPing obj_conv;
16239         obj_conv.inner = (void*)(obj & (~1));
16240         obj_conv.is_owned = false;
16241         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
16242         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16243         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16244         CVec_u8Z_free(ret_var);
16245         return ret_arr;
16246 }
16247
16248 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
16249         LDKu8slice ser_ref;
16250         ser_ref.datalen = *((uint32_t*)ser);
16251         ser_ref.data = (int8_t*)(ser + 4);
16252         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
16253         *ret_conv = Ping_read(ser_ref);
16254         return (long)ret_conv;
16255 }
16256
16257 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
16258         LDKPong obj_conv;
16259         obj_conv.inner = (void*)(obj & (~1));
16260         obj_conv.is_owned = false;
16261         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
16262         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16263         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16264         CVec_u8Z_free(ret_var);
16265         return ret_arr;
16266 }
16267
16268 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
16269         LDKu8slice ser_ref;
16270         ser_ref.datalen = *((uint32_t*)ser);
16271         ser_ref.data = (int8_t*)(ser + 4);
16272         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
16273         *ret_conv = Pong_read(ser_ref);
16274         return (long)ret_conv;
16275 }
16276
16277 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
16278         LDKUnsignedChannelAnnouncement obj_conv;
16279         obj_conv.inner = (void*)(obj & (~1));
16280         obj_conv.is_owned = false;
16281         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
16282         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16283         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16284         CVec_u8Z_free(ret_var);
16285         return ret_arr;
16286 }
16287
16288 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
16289         LDKu8slice ser_ref;
16290         ser_ref.datalen = *((uint32_t*)ser);
16291         ser_ref.data = (int8_t*)(ser + 4);
16292         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
16293         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
16294         return (long)ret_conv;
16295 }
16296
16297 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
16298         LDKChannelAnnouncement obj_conv;
16299         obj_conv.inner = (void*)(obj & (~1));
16300         obj_conv.is_owned = false;
16301         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
16302         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16303         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16304         CVec_u8Z_free(ret_var);
16305         return ret_arr;
16306 }
16307
16308 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
16309         LDKu8slice ser_ref;
16310         ser_ref.datalen = *((uint32_t*)ser);
16311         ser_ref.data = (int8_t*)(ser + 4);
16312         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
16313         *ret_conv = ChannelAnnouncement_read(ser_ref);
16314         return (long)ret_conv;
16315 }
16316
16317 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
16318         LDKUnsignedChannelUpdate obj_conv;
16319         obj_conv.inner = (void*)(obj & (~1));
16320         obj_conv.is_owned = false;
16321         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
16322         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16323         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16324         CVec_u8Z_free(ret_var);
16325         return ret_arr;
16326 }
16327
16328 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
16329         LDKu8slice ser_ref;
16330         ser_ref.datalen = *((uint32_t*)ser);
16331         ser_ref.data = (int8_t*)(ser + 4);
16332         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
16333         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
16334         return (long)ret_conv;
16335 }
16336
16337 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
16338         LDKChannelUpdate obj_conv;
16339         obj_conv.inner = (void*)(obj & (~1));
16340         obj_conv.is_owned = false;
16341         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
16342         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16343         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16344         CVec_u8Z_free(ret_var);
16345         return ret_arr;
16346 }
16347
16348 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
16349         LDKu8slice ser_ref;
16350         ser_ref.datalen = *((uint32_t*)ser);
16351         ser_ref.data = (int8_t*)(ser + 4);
16352         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
16353         *ret_conv = ChannelUpdate_read(ser_ref);
16354         return (long)ret_conv;
16355 }
16356
16357 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
16358         LDKErrorMessage obj_conv;
16359         obj_conv.inner = (void*)(obj & (~1));
16360         obj_conv.is_owned = false;
16361         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
16362         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16363         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16364         CVec_u8Z_free(ret_var);
16365         return ret_arr;
16366 }
16367
16368 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
16369         LDKu8slice ser_ref;
16370         ser_ref.datalen = *((uint32_t*)ser);
16371         ser_ref.data = (int8_t*)(ser + 4);
16372         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
16373         *ret_conv = ErrorMessage_read(ser_ref);
16374         return (long)ret_conv;
16375 }
16376
16377 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
16378         LDKUnsignedNodeAnnouncement obj_conv;
16379         obj_conv.inner = (void*)(obj & (~1));
16380         obj_conv.is_owned = false;
16381         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
16382         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16383         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16384         CVec_u8Z_free(ret_var);
16385         return ret_arr;
16386 }
16387
16388 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
16389         LDKu8slice ser_ref;
16390         ser_ref.datalen = *((uint32_t*)ser);
16391         ser_ref.data = (int8_t*)(ser + 4);
16392         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16393         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
16394         return (long)ret_conv;
16395 }
16396
16397 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
16398         LDKNodeAnnouncement obj_conv;
16399         obj_conv.inner = (void*)(obj & (~1));
16400         obj_conv.is_owned = false;
16401         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
16402         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16403         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16404         CVec_u8Z_free(ret_var);
16405         return ret_arr;
16406 }
16407
16408 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
16409         LDKu8slice ser_ref;
16410         ser_ref.datalen = *((uint32_t*)ser);
16411         ser_ref.data = (int8_t*)(ser + 4);
16412         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16413         *ret_conv = NodeAnnouncement_read(ser_ref);
16414         return (long)ret_conv;
16415 }
16416
16417 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
16418         LDKu8slice ser_ref;
16419         ser_ref.datalen = *((uint32_t*)ser);
16420         ser_ref.data = (int8_t*)(ser + 4);
16421         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16422         *ret_conv = QueryShortChannelIds_read(ser_ref);
16423         return (long)ret_conv;
16424 }
16425
16426 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
16427         LDKQueryShortChannelIds obj_conv;
16428         obj_conv.inner = (void*)(obj & (~1));
16429         obj_conv.is_owned = false;
16430         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
16431         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16432         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16433         CVec_u8Z_free(ret_var);
16434         return ret_arr;
16435 }
16436
16437 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
16438         LDKu8slice ser_ref;
16439         ser_ref.datalen = *((uint32_t*)ser);
16440         ser_ref.data = (int8_t*)(ser + 4);
16441         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16442         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
16443         return (long)ret_conv;
16444 }
16445
16446 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
16447         LDKReplyShortChannelIdsEnd obj_conv;
16448         obj_conv.inner = (void*)(obj & (~1));
16449         obj_conv.is_owned = false;
16450         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
16451         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16452         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16453         CVec_u8Z_free(ret_var);
16454         return ret_arr;
16455 }
16456
16457 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
16458         LDKQueryChannelRange this_arg_conv;
16459         this_arg_conv.inner = (void*)(this_arg & (~1));
16460         this_arg_conv.is_owned = false;
16461         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
16462         return ret_val;
16463 }
16464
16465 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
16466         LDKu8slice ser_ref;
16467         ser_ref.datalen = *((uint32_t*)ser);
16468         ser_ref.data = (int8_t*)(ser + 4);
16469         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16470         *ret_conv = QueryChannelRange_read(ser_ref);
16471         return (long)ret_conv;
16472 }
16473
16474 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
16475         LDKQueryChannelRange obj_conv;
16476         obj_conv.inner = (void*)(obj & (~1));
16477         obj_conv.is_owned = false;
16478         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
16479         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16480         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16481         CVec_u8Z_free(ret_var);
16482         return ret_arr;
16483 }
16484
16485 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
16486         LDKu8slice ser_ref;
16487         ser_ref.datalen = *((uint32_t*)ser);
16488         ser_ref.data = (int8_t*)(ser + 4);
16489         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16490         *ret_conv = ReplyChannelRange_read(ser_ref);
16491         return (long)ret_conv;
16492 }
16493
16494 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
16495         LDKReplyChannelRange obj_conv;
16496         obj_conv.inner = (void*)(obj & (~1));
16497         obj_conv.is_owned = false;
16498         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
16499         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16500         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16501         CVec_u8Z_free(ret_var);
16502         return ret_arr;
16503 }
16504
16505 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
16506         LDKu8slice ser_ref;
16507         ser_ref.datalen = *((uint32_t*)ser);
16508         ser_ref.data = (int8_t*)(ser + 4);
16509         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16510         *ret_conv = GossipTimestampFilter_read(ser_ref);
16511         return (long)ret_conv;
16512 }
16513
16514 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
16515         LDKGossipTimestampFilter obj_conv;
16516         obj_conv.inner = (void*)(obj & (~1));
16517         obj_conv.is_owned = false;
16518         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
16519         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16520         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16521         CVec_u8Z_free(ret_var);
16522         return ret_arr;
16523 }
16524
16525 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
16526         LDKIgnoringMessageHandler this_obj_conv;
16527         this_obj_conv.inner = (void*)(this_obj & (~1));
16528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16529         IgnoringMessageHandler_free(this_obj_conv);
16530 }
16531
16532 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
16533         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
16534         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16535         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16536         long ret_ref = (long)ret_var.inner;
16537         if (ret_var.is_owned) {
16538                 ret_ref |= 1;
16539         }
16540         return ret_ref;
16541 }
16542
16543 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
16544         LDKIgnoringMessageHandler this_arg_conv;
16545         this_arg_conv.inner = (void*)(this_arg & (~1));
16546         this_arg_conv.is_owned = false;
16547         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16548         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16549         return (long)ret;
16550 }
16551
16552 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
16553         LDKIgnoringMessageHandler this_arg_conv;
16554         this_arg_conv.inner = (void*)(this_arg & (~1));
16555         this_arg_conv.is_owned = false;
16556         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
16557         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
16558         return (long)ret;
16559 }
16560
16561 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
16562         LDKErroringMessageHandler this_obj_conv;
16563         this_obj_conv.inner = (void*)(this_obj & (~1));
16564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16565         ErroringMessageHandler_free(this_obj_conv);
16566 }
16567
16568 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
16569         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
16570         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16571         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16572         long ret_ref = (long)ret_var.inner;
16573         if (ret_var.is_owned) {
16574                 ret_ref |= 1;
16575         }
16576         return ret_ref;
16577 }
16578
16579 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
16580         LDKErroringMessageHandler this_arg_conv;
16581         this_arg_conv.inner = (void*)(this_arg & (~1));
16582         this_arg_conv.is_owned = false;
16583         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16584         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
16585         return (long)ret;
16586 }
16587
16588 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
16589         LDKErroringMessageHandler this_arg_conv;
16590         this_arg_conv.inner = (void*)(this_arg & (~1));
16591         this_arg_conv.is_owned = false;
16592         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16593         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
16594         return (long)ret;
16595 }
16596
16597 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
16598         LDKMessageHandler this_obj_conv;
16599         this_obj_conv.inner = (void*)(this_obj & (~1));
16600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16601         MessageHandler_free(this_obj_conv);
16602 }
16603
16604 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
16605         LDKMessageHandler this_ptr_conv;
16606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16607         this_ptr_conv.is_owned = false;
16608         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
16609         return ret_ret;
16610 }
16611
16612 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
16613         LDKMessageHandler this_ptr_conv;
16614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16615         this_ptr_conv.is_owned = false;
16616         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
16617         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
16618 }
16619
16620 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
16621         LDKMessageHandler this_ptr_conv;
16622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16623         this_ptr_conv.is_owned = false;
16624         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
16625         return ret_ret;
16626 }
16627
16628 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
16629         LDKMessageHandler this_ptr_conv;
16630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16631         this_ptr_conv.is_owned = false;
16632         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
16633         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
16634 }
16635
16636 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
16637         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
16638         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
16639         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
16640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16642         long ret_ref = (long)ret_var.inner;
16643         if (ret_var.is_owned) {
16644                 ret_ref |= 1;
16645         }
16646         return ret_ref;
16647 }
16648
16649 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
16650         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
16651         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
16652         *ret = SocketDescriptor_clone(orig_conv);
16653         return (long)ret;
16654 }
16655
16656 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
16657         if ((this_ptr & 1) != 0) return;
16658         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
16659         FREE((void*)this_ptr);
16660         SocketDescriptor_free(this_ptr_conv);
16661 }
16662
16663 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
16664         LDKPeerHandleError this_obj_conv;
16665         this_obj_conv.inner = (void*)(this_obj & (~1));
16666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16667         PeerHandleError_free(this_obj_conv);
16668 }
16669
16670 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
16671         LDKPeerHandleError this_ptr_conv;
16672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16673         this_ptr_conv.is_owned = false;
16674         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
16675         return ret_val;
16676 }
16677
16678 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
16679         LDKPeerHandleError this_ptr_conv;
16680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16681         this_ptr_conv.is_owned = false;
16682         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
16683 }
16684
16685 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
16686         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
16687         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16688         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16689         long ret_ref = (long)ret_var.inner;
16690         if (ret_var.is_owned) {
16691                 ret_ref |= 1;
16692         }
16693         return ret_ref;
16694 }
16695
16696 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
16697         LDKPeerHandleError orig_conv;
16698         orig_conv.inner = (void*)(orig & (~1));
16699         orig_conv.is_owned = false;
16700         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
16701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16703         long ret_ref = (long)ret_var.inner;
16704         if (ret_var.is_owned) {
16705                 ret_ref |= 1;
16706         }
16707         return ret_ref;
16708 }
16709
16710 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
16711         LDKPeerManager this_obj_conv;
16712         this_obj_conv.inner = (void*)(this_obj & (~1));
16713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16714         PeerManager_free(this_obj_conv);
16715 }
16716
16717 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) {
16718         LDKMessageHandler message_handler_conv;
16719         message_handler_conv.inner = (void*)(message_handler & (~1));
16720         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
16721         // Warning: we need a move here but no clone is available for LDKMessageHandler
16722         LDKSecretKey our_node_secret_ref;
16723         CHECK(*((uint32_t*)our_node_secret) == 32);
16724         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
16725         unsigned char ephemeral_random_data_arr[32];
16726         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
16727         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
16728         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
16729         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16730         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
16731         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16732         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16733         long ret_ref = (long)ret_var.inner;
16734         if (ret_var.is_owned) {
16735                 ret_ref |= 1;
16736         }
16737         return ret_ref;
16738 }
16739
16740 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
16741         LDKPeerManager this_arg_conv;
16742         this_arg_conv.inner = (void*)(this_arg & (~1));
16743         this_arg_conv.is_owned = false;
16744         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
16745         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
16746         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
16747         for (size_t m = 0; m < ret_var.datalen; m++) {
16748                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16749                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
16750                 ret_arr_ptr[m] = ret_conv_12_arr;
16751         }
16752         FREE(ret_var.data);
16753         return ret_arr;
16754 }
16755
16756 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
16757         LDKPeerManager this_arg_conv;
16758         this_arg_conv.inner = (void*)(this_arg & (~1));
16759         this_arg_conv.is_owned = false;
16760         LDKPublicKey their_node_id_ref;
16761         CHECK(*((uint32_t*)their_node_id) == 33);
16762         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
16763         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16764         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16765         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
16766         return (long)ret_conv;
16767 }
16768
16769 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
16770         LDKPeerManager this_arg_conv;
16771         this_arg_conv.inner = (void*)(this_arg & (~1));
16772         this_arg_conv.is_owned = false;
16773         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16774         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16775         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
16776         return (long)ret_conv;
16777 }
16778
16779 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
16780         LDKPeerManager this_arg_conv;
16781         this_arg_conv.inner = (void*)(this_arg & (~1));
16782         this_arg_conv.is_owned = false;
16783         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16784         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16785         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
16786         return (long)ret_conv;
16787 }
16788
16789 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
16790         LDKPeerManager this_arg_conv;
16791         this_arg_conv.inner = (void*)(this_arg & (~1));
16792         this_arg_conv.is_owned = false;
16793         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
16794         LDKu8slice data_ref;
16795         data_ref.datalen = *((uint32_t*)data);
16796         data_ref.data = (int8_t*)(data + 4);
16797         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16798         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
16799         return (long)ret_conv;
16800 }
16801
16802 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
16803         LDKPeerManager this_arg_conv;
16804         this_arg_conv.inner = (void*)(this_arg & (~1));
16805         this_arg_conv.is_owned = false;
16806         PeerManager_process_events(&this_arg_conv);
16807 }
16808
16809 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
16810         LDKPeerManager this_arg_conv;
16811         this_arg_conv.inner = (void*)(this_arg & (~1));
16812         this_arg_conv.is_owned = false;
16813         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16814         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
16815 }
16816
16817 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
16818         LDKPeerManager this_arg_conv;
16819         this_arg_conv.inner = (void*)(this_arg & (~1));
16820         this_arg_conv.is_owned = false;
16821         LDKPublicKey node_id_ref;
16822         CHECK(*((uint32_t*)node_id) == 33);
16823         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16824         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
16825 }
16826
16827 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
16828         LDKPeerManager this_arg_conv;
16829         this_arg_conv.inner = (void*)(this_arg & (~1));
16830         this_arg_conv.is_owned = false;
16831         PeerManager_timer_tick_occurred(&this_arg_conv);
16832 }
16833
16834 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
16835         unsigned char commitment_seed_arr[32];
16836         CHECK(*((uint32_t*)commitment_seed) == 32);
16837         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
16838         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
16839         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16840         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
16841         return ret_arr;
16842 }
16843
16844 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
16845         LDKPublicKey per_commitment_point_ref;
16846         CHECK(*((uint32_t*)per_commitment_point) == 33);
16847         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16848         unsigned char base_secret_arr[32];
16849         CHECK(*((uint32_t*)base_secret) == 32);
16850         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
16851         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
16852         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16853         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
16854         return (long)ret_conv;
16855 }
16856
16857 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
16858         LDKPublicKey per_commitment_point_ref;
16859         CHECK(*((uint32_t*)per_commitment_point) == 33);
16860         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16861         LDKPublicKey base_point_ref;
16862         CHECK(*((uint32_t*)base_point) == 33);
16863         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
16864         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16865         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
16866         return (long)ret_conv;
16867 }
16868
16869 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
16870         unsigned char per_commitment_secret_arr[32];
16871         CHECK(*((uint32_t*)per_commitment_secret) == 32);
16872         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
16873         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
16874         unsigned char countersignatory_revocation_base_secret_arr[32];
16875         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
16876         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
16877         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
16878         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16879         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
16880         return (long)ret_conv;
16881 }
16882
16883 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
16884         LDKPublicKey per_commitment_point_ref;
16885         CHECK(*((uint32_t*)per_commitment_point) == 33);
16886         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16887         LDKPublicKey countersignatory_revocation_base_point_ref;
16888         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
16889         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
16890         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16891         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
16892         return (long)ret_conv;
16893 }
16894
16895 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
16896         LDKTxCreationKeys this_obj_conv;
16897         this_obj_conv.inner = (void*)(this_obj & (~1));
16898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16899         TxCreationKeys_free(this_obj_conv);
16900 }
16901
16902 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
16903         LDKTxCreationKeys this_ptr_conv;
16904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16905         this_ptr_conv.is_owned = false;
16906         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16907         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16908         return ret_arr;
16909 }
16910
16911 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16912         LDKTxCreationKeys this_ptr_conv;
16913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16914         this_ptr_conv.is_owned = false;
16915         LDKPublicKey val_ref;
16916         CHECK(*((uint32_t*)val) == 33);
16917         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16918         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
16919 }
16920
16921 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
16922         LDKTxCreationKeys this_ptr_conv;
16923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16924         this_ptr_conv.is_owned = false;
16925         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16926         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
16927         return ret_arr;
16928 }
16929
16930 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
16931         LDKTxCreationKeys this_ptr_conv;
16932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16933         this_ptr_conv.is_owned = false;
16934         LDKPublicKey val_ref;
16935         CHECK(*((uint32_t*)val) == 33);
16936         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16937         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
16938 }
16939
16940 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
16941         LDKTxCreationKeys this_ptr_conv;
16942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16943         this_ptr_conv.is_owned = false;
16944         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16945         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
16946         return ret_arr;
16947 }
16948
16949 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
16950         LDKTxCreationKeys this_ptr_conv;
16951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16952         this_ptr_conv.is_owned = false;
16953         LDKPublicKey val_ref;
16954         CHECK(*((uint32_t*)val) == 33);
16955         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16956         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
16957 }
16958
16959 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
16960         LDKTxCreationKeys this_ptr_conv;
16961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16962         this_ptr_conv.is_owned = false;
16963         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16964         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
16965         return ret_arr;
16966 }
16967
16968 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
16969         LDKTxCreationKeys this_ptr_conv;
16970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16971         this_ptr_conv.is_owned = false;
16972         LDKPublicKey val_ref;
16973         CHECK(*((uint32_t*)val) == 33);
16974         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16975         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
16976 }
16977
16978 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
16979         LDKTxCreationKeys this_ptr_conv;
16980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16981         this_ptr_conv.is_owned = false;
16982         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16983         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
16984         return ret_arr;
16985 }
16986
16987 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
16988         LDKTxCreationKeys this_ptr_conv;
16989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16990         this_ptr_conv.is_owned = false;
16991         LDKPublicKey val_ref;
16992         CHECK(*((uint32_t*)val) == 33);
16993         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16994         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
16995 }
16996
16997 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) {
16998         LDKPublicKey per_commitment_point_arg_ref;
16999         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
17000         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
17001         LDKPublicKey revocation_key_arg_ref;
17002         CHECK(*((uint32_t*)revocation_key_arg) == 33);
17003         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
17004         LDKPublicKey broadcaster_htlc_key_arg_ref;
17005         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
17006         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
17007         LDKPublicKey countersignatory_htlc_key_arg_ref;
17008         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
17009         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
17010         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
17011         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
17012         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
17013         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);
17014         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17015         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17016         long ret_ref = (long)ret_var.inner;
17017         if (ret_var.is_owned) {
17018                 ret_ref |= 1;
17019         }
17020         return ret_ref;
17021 }
17022
17023 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
17024         LDKTxCreationKeys orig_conv;
17025         orig_conv.inner = (void*)(orig & (~1));
17026         orig_conv.is_owned = false;
17027         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
17028         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17029         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17030         long ret_ref = (long)ret_var.inner;
17031         if (ret_var.is_owned) {
17032                 ret_ref |= 1;
17033         }
17034         return ret_ref;
17035 }
17036
17037 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
17038         LDKTxCreationKeys obj_conv;
17039         obj_conv.inner = (void*)(obj & (~1));
17040         obj_conv.is_owned = false;
17041         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
17042         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17043         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17044         CVec_u8Z_free(ret_var);
17045         return ret_arr;
17046 }
17047
17048 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
17049         LDKu8slice ser_ref;
17050         ser_ref.datalen = *((uint32_t*)ser);
17051         ser_ref.data = (int8_t*)(ser + 4);
17052         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
17053         *ret_conv = TxCreationKeys_read(ser_ref);
17054         return (long)ret_conv;
17055 }
17056
17057 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
17058         LDKChannelPublicKeys this_obj_conv;
17059         this_obj_conv.inner = (void*)(this_obj & (~1));
17060         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17061         ChannelPublicKeys_free(this_obj_conv);
17062 }
17063
17064 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
17065         LDKChannelPublicKeys this_ptr_conv;
17066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17067         this_ptr_conv.is_owned = false;
17068         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17069         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
17070         return ret_arr;
17071 }
17072
17073 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
17074         LDKChannelPublicKeys this_ptr_conv;
17075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17076         this_ptr_conv.is_owned = false;
17077         LDKPublicKey val_ref;
17078         CHECK(*((uint32_t*)val) == 33);
17079         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17080         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
17081 }
17082
17083 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
17084         LDKChannelPublicKeys this_ptr_conv;
17085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17086         this_ptr_conv.is_owned = false;
17087         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17088         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
17089         return ret_arr;
17090 }
17091
17092 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
17093         LDKChannelPublicKeys this_ptr_conv;
17094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17095         this_ptr_conv.is_owned = false;
17096         LDKPublicKey val_ref;
17097         CHECK(*((uint32_t*)val) == 33);
17098         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17099         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
17100 }
17101
17102 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
17103         LDKChannelPublicKeys this_ptr_conv;
17104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17105         this_ptr_conv.is_owned = false;
17106         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17107         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
17108         return ret_arr;
17109 }
17110
17111 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
17112         LDKChannelPublicKeys this_ptr_conv;
17113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17114         this_ptr_conv.is_owned = false;
17115         LDKPublicKey val_ref;
17116         CHECK(*((uint32_t*)val) == 33);
17117         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17118         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
17119 }
17120
17121 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
17122         LDKChannelPublicKeys this_ptr_conv;
17123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17124         this_ptr_conv.is_owned = false;
17125         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17126         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
17127         return ret_arr;
17128 }
17129
17130 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
17131         LDKChannelPublicKeys this_ptr_conv;
17132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17133         this_ptr_conv.is_owned = false;
17134         LDKPublicKey val_ref;
17135         CHECK(*((uint32_t*)val) == 33);
17136         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17137         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17138 }
17139
17140 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
17141         LDKChannelPublicKeys this_ptr_conv;
17142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17143         this_ptr_conv.is_owned = false;
17144         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17145         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
17146         return ret_arr;
17147 }
17148
17149 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
17150         LDKChannelPublicKeys this_ptr_conv;
17151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17152         this_ptr_conv.is_owned = false;
17153         LDKPublicKey val_ref;
17154         CHECK(*((uint32_t*)val) == 33);
17155         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17156         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
17157 }
17158
17159 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) {
17160         LDKPublicKey funding_pubkey_arg_ref;
17161         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
17162         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
17163         LDKPublicKey revocation_basepoint_arg_ref;
17164         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
17165         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
17166         LDKPublicKey payment_point_arg_ref;
17167         CHECK(*((uint32_t*)payment_point_arg) == 33);
17168         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
17169         LDKPublicKey delayed_payment_basepoint_arg_ref;
17170         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
17171         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
17172         LDKPublicKey htlc_basepoint_arg_ref;
17173         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
17174         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
17175         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);
17176         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17177         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17178         long ret_ref = (long)ret_var.inner;
17179         if (ret_var.is_owned) {
17180                 ret_ref |= 1;
17181         }
17182         return ret_ref;
17183 }
17184
17185 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
17186         LDKChannelPublicKeys orig_conv;
17187         orig_conv.inner = (void*)(orig & (~1));
17188         orig_conv.is_owned = false;
17189         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
17190         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17191         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17192         long ret_ref = (long)ret_var.inner;
17193         if (ret_var.is_owned) {
17194                 ret_ref |= 1;
17195         }
17196         return ret_ref;
17197 }
17198
17199 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
17200         LDKChannelPublicKeys obj_conv;
17201         obj_conv.inner = (void*)(obj & (~1));
17202         obj_conv.is_owned = false;
17203         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
17204         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17205         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17206         CVec_u8Z_free(ret_var);
17207         return ret_arr;
17208 }
17209
17210 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
17211         LDKu8slice ser_ref;
17212         ser_ref.datalen = *((uint32_t*)ser);
17213         ser_ref.data = (int8_t*)(ser + 4);
17214         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
17215         *ret_conv = ChannelPublicKeys_read(ser_ref);
17216         return (long)ret_conv;
17217 }
17218
17219 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) {
17220         LDKPublicKey per_commitment_point_ref;
17221         CHECK(*((uint32_t*)per_commitment_point) == 33);
17222         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
17223         LDKPublicKey broadcaster_delayed_payment_base_ref;
17224         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
17225         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
17226         LDKPublicKey broadcaster_htlc_base_ref;
17227         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
17228         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
17229         LDKPublicKey countersignatory_revocation_base_ref;
17230         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
17231         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
17232         LDKPublicKey countersignatory_htlc_base_ref;
17233         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
17234         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
17235         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17236         *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);
17237         return (long)ret_conv;
17238 }
17239
17240 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
17241         LDKPublicKey per_commitment_point_ref;
17242         CHECK(*((uint32_t*)per_commitment_point) == 33);
17243         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
17244         LDKChannelPublicKeys broadcaster_keys_conv;
17245         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17246         broadcaster_keys_conv.is_owned = false;
17247         LDKChannelPublicKeys countersignatory_keys_conv;
17248         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17249         countersignatory_keys_conv.is_owned = false;
17250         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
17251         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
17252         return (long)ret_conv;
17253 }
17254
17255 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
17256         LDKPublicKey revocation_key_ref;
17257         CHECK(*((uint32_t*)revocation_key) == 33);
17258         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
17259         LDKPublicKey broadcaster_delayed_payment_key_ref;
17260         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
17261         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
17262         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
17263         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17264         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17265         CVec_u8Z_free(ret_var);
17266         return ret_arr;
17267 }
17268
17269 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
17270         LDKHTLCOutputInCommitment this_obj_conv;
17271         this_obj_conv.inner = (void*)(this_obj & (~1));
17272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17273         HTLCOutputInCommitment_free(this_obj_conv);
17274 }
17275
17276 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
17277         LDKHTLCOutputInCommitment this_ptr_conv;
17278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17279         this_ptr_conv.is_owned = false;
17280         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
17281         return ret_val;
17282 }
17283
17284 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
17285         LDKHTLCOutputInCommitment this_ptr_conv;
17286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17287         this_ptr_conv.is_owned = false;
17288         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
17289 }
17290
17291 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
17292         LDKHTLCOutputInCommitment this_ptr_conv;
17293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17294         this_ptr_conv.is_owned = false;
17295         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
17296         return ret_val;
17297 }
17298
17299 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
17300         LDKHTLCOutputInCommitment this_ptr_conv;
17301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17302         this_ptr_conv.is_owned = false;
17303         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
17304 }
17305
17306 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
17307         LDKHTLCOutputInCommitment this_ptr_conv;
17308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17309         this_ptr_conv.is_owned = false;
17310         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
17311         return ret_val;
17312 }
17313
17314 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
17315         LDKHTLCOutputInCommitment this_ptr_conv;
17316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17317         this_ptr_conv.is_owned = false;
17318         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
17319 }
17320
17321 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
17322         LDKHTLCOutputInCommitment this_ptr_conv;
17323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17324         this_ptr_conv.is_owned = false;
17325         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17326         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
17327         return ret_arr;
17328 }
17329
17330 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
17331         LDKHTLCOutputInCommitment this_ptr_conv;
17332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17333         this_ptr_conv.is_owned = false;
17334         LDKThirtyTwoBytes val_ref;
17335         CHECK(*((uint32_t*)val) == 32);
17336         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17337         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
17338 }
17339
17340 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
17341         LDKHTLCOutputInCommitment this_ptr_conv;
17342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17343         this_ptr_conv.is_owned = false;
17344         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
17345         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
17346         long ret_ref = (long)ret_copy;
17347         return ret_ref;
17348 }
17349
17350 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
17351         LDKHTLCOutputInCommitment this_ptr_conv;
17352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17353         this_ptr_conv.is_owned = false;
17354         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
17355         FREE((void*)val);
17356         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
17357 }
17358
17359 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) {
17360         LDKThirtyTwoBytes payment_hash_arg_ref;
17361         CHECK(*((uint32_t*)payment_hash_arg) == 32);
17362         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
17363         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
17364         FREE((void*)transaction_output_index_arg);
17365         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
17366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17368         long ret_ref = (long)ret_var.inner;
17369         if (ret_var.is_owned) {
17370                 ret_ref |= 1;
17371         }
17372         return ret_ref;
17373 }
17374
17375 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
17376         LDKHTLCOutputInCommitment orig_conv;
17377         orig_conv.inner = (void*)(orig & (~1));
17378         orig_conv.is_owned = false;
17379         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
17380         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17381         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17382         long ret_ref = (long)ret_var.inner;
17383         if (ret_var.is_owned) {
17384                 ret_ref |= 1;
17385         }
17386         return ret_ref;
17387 }
17388
17389 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
17390         LDKHTLCOutputInCommitment obj_conv;
17391         obj_conv.inner = (void*)(obj & (~1));
17392         obj_conv.is_owned = false;
17393         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
17394         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17395         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17396         CVec_u8Z_free(ret_var);
17397         return ret_arr;
17398 }
17399
17400 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
17401         LDKu8slice ser_ref;
17402         ser_ref.datalen = *((uint32_t*)ser);
17403         ser_ref.data = (int8_t*)(ser + 4);
17404         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
17405         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
17406         return (long)ret_conv;
17407 }
17408
17409 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
17410         LDKHTLCOutputInCommitment htlc_conv;
17411         htlc_conv.inner = (void*)(htlc & (~1));
17412         htlc_conv.is_owned = false;
17413         LDKTxCreationKeys keys_conv;
17414         keys_conv.inner = (void*)(keys & (~1));
17415         keys_conv.is_owned = false;
17416         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
17417         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17418         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17419         CVec_u8Z_free(ret_var);
17420         return ret_arr;
17421 }
17422
17423 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
17424         LDKPublicKey broadcaster_ref;
17425         CHECK(*((uint32_t*)broadcaster) == 33);
17426         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
17427         LDKPublicKey countersignatory_ref;
17428         CHECK(*((uint32_t*)countersignatory) == 33);
17429         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
17430         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
17431         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17432         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17433         CVec_u8Z_free(ret_var);
17434         return ret_arr;
17435 }
17436
17437 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) {
17438         unsigned char prev_hash_arr[32];
17439         CHECK(*((uint32_t*)prev_hash) == 32);
17440         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
17441         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
17442         LDKHTLCOutputInCommitment htlc_conv;
17443         htlc_conv.inner = (void*)(htlc & (~1));
17444         htlc_conv.is_owned = false;
17445         LDKPublicKey broadcaster_delayed_payment_key_ref;
17446         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
17447         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
17448         LDKPublicKey revocation_key_ref;
17449         CHECK(*((uint32_t*)revocation_key) == 33);
17450         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
17451         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
17452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17454         Transaction_free(ret_var);
17455         return ret_arr;
17456 }
17457
17458 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
17459         LDKChannelTransactionParameters this_obj_conv;
17460         this_obj_conv.inner = (void*)(this_obj & (~1));
17461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17462         ChannelTransactionParameters_free(this_obj_conv);
17463 }
17464
17465 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
17466         LDKChannelTransactionParameters this_ptr_conv;
17467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17468         this_ptr_conv.is_owned = false;
17469         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
17470         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17471         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17472         long ret_ref = (long)ret_var.inner;
17473         if (ret_var.is_owned) {
17474                 ret_ref |= 1;
17475         }
17476         return ret_ref;
17477 }
17478
17479 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
17480         LDKChannelTransactionParameters this_ptr_conv;
17481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17482         this_ptr_conv.is_owned = false;
17483         LDKChannelPublicKeys val_conv;
17484         val_conv.inner = (void*)(val & (~1));
17485         val_conv.is_owned = (val & 1) || (val == 0);
17486         val_conv = ChannelPublicKeys_clone(&val_conv);
17487         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
17488 }
17489
17490 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
17491         LDKChannelTransactionParameters this_ptr_conv;
17492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17493         this_ptr_conv.is_owned = false;
17494         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
17495         return ret_val;
17496 }
17497
17498 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
17499         LDKChannelTransactionParameters this_ptr_conv;
17500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17501         this_ptr_conv.is_owned = false;
17502         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
17503 }
17504
17505 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
17506         LDKChannelTransactionParameters this_ptr_conv;
17507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17508         this_ptr_conv.is_owned = false;
17509         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
17510         return ret_val;
17511 }
17512
17513 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
17514         LDKChannelTransactionParameters this_ptr_conv;
17515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17516         this_ptr_conv.is_owned = false;
17517         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
17518 }
17519
17520 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
17521         LDKChannelTransactionParameters this_ptr_conv;
17522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17523         this_ptr_conv.is_owned = false;
17524         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
17525         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17526         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17527         long ret_ref = (long)ret_var.inner;
17528         if (ret_var.is_owned) {
17529                 ret_ref |= 1;
17530         }
17531         return ret_ref;
17532 }
17533
17534 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
17535         LDKChannelTransactionParameters this_ptr_conv;
17536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17537         this_ptr_conv.is_owned = false;
17538         LDKCounterpartyChannelTransactionParameters val_conv;
17539         val_conv.inner = (void*)(val & (~1));
17540         val_conv.is_owned = (val & 1) || (val == 0);
17541         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
17542         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
17543 }
17544
17545 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
17546         LDKChannelTransactionParameters this_ptr_conv;
17547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17548         this_ptr_conv.is_owned = false;
17549         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
17550         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17551         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17552         long ret_ref = (long)ret_var.inner;
17553         if (ret_var.is_owned) {
17554                 ret_ref |= 1;
17555         }
17556         return ret_ref;
17557 }
17558
17559 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
17560         LDKChannelTransactionParameters this_ptr_conv;
17561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17562         this_ptr_conv.is_owned = false;
17563         LDKOutPoint val_conv;
17564         val_conv.inner = (void*)(val & (~1));
17565         val_conv.is_owned = (val & 1) || (val == 0);
17566         val_conv = OutPoint_clone(&val_conv);
17567         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
17568 }
17569
17570 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) {
17571         LDKChannelPublicKeys holder_pubkeys_arg_conv;
17572         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
17573         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
17574         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
17575         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
17576         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
17577         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
17578         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
17579         LDKOutPoint funding_outpoint_arg_conv;
17580         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
17581         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
17582         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
17583         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);
17584         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17585         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17586         long ret_ref = (long)ret_var.inner;
17587         if (ret_var.is_owned) {
17588                 ret_ref |= 1;
17589         }
17590         return ret_ref;
17591 }
17592
17593 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
17594         LDKChannelTransactionParameters orig_conv;
17595         orig_conv.inner = (void*)(orig & (~1));
17596         orig_conv.is_owned = false;
17597         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
17598         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17599         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17600         long ret_ref = (long)ret_var.inner;
17601         if (ret_var.is_owned) {
17602                 ret_ref |= 1;
17603         }
17604         return ret_ref;
17605 }
17606
17607 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
17608         LDKCounterpartyChannelTransactionParameters this_obj_conv;
17609         this_obj_conv.inner = (void*)(this_obj & (~1));
17610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17611         CounterpartyChannelTransactionParameters_free(this_obj_conv);
17612 }
17613
17614 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
17615         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17617         this_ptr_conv.is_owned = false;
17618         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
17619         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17620         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17621         long ret_ref = (long)ret_var.inner;
17622         if (ret_var.is_owned) {
17623                 ret_ref |= 1;
17624         }
17625         return ret_ref;
17626 }
17627
17628 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
17629         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17631         this_ptr_conv.is_owned = false;
17632         LDKChannelPublicKeys val_conv;
17633         val_conv.inner = (void*)(val & (~1));
17634         val_conv.is_owned = (val & 1) || (val == 0);
17635         val_conv = ChannelPublicKeys_clone(&val_conv);
17636         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
17637 }
17638
17639 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
17640         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17642         this_ptr_conv.is_owned = false;
17643         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
17644         return ret_val;
17645 }
17646
17647 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
17648         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
17649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17650         this_ptr_conv.is_owned = false;
17651         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
17652 }
17653
17654 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
17655         LDKChannelPublicKeys pubkeys_arg_conv;
17656         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
17657         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
17658         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
17659         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
17660         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17661         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17662         long ret_ref = (long)ret_var.inner;
17663         if (ret_var.is_owned) {
17664                 ret_ref |= 1;
17665         }
17666         return ret_ref;
17667 }
17668
17669 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
17670         LDKCounterpartyChannelTransactionParameters orig_conv;
17671         orig_conv.inner = (void*)(orig & (~1));
17672         orig_conv.is_owned = false;
17673         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
17674         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17675         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17676         long ret_ref = (long)ret_var.inner;
17677         if (ret_var.is_owned) {
17678                 ret_ref |= 1;
17679         }
17680         return ret_ref;
17681 }
17682
17683 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
17684         LDKChannelTransactionParameters this_arg_conv;
17685         this_arg_conv.inner = (void*)(this_arg & (~1));
17686         this_arg_conv.is_owned = false;
17687         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
17688         return ret_val;
17689 }
17690
17691 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
17692         LDKChannelTransactionParameters this_arg_conv;
17693         this_arg_conv.inner = (void*)(this_arg & (~1));
17694         this_arg_conv.is_owned = false;
17695         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
17696         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17697         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17698         long ret_ref = (long)ret_var.inner;
17699         if (ret_var.is_owned) {
17700                 ret_ref |= 1;
17701         }
17702         return ret_ref;
17703 }
17704
17705 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
17706         LDKChannelTransactionParameters this_arg_conv;
17707         this_arg_conv.inner = (void*)(this_arg & (~1));
17708         this_arg_conv.is_owned = false;
17709         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
17710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17712         long ret_ref = (long)ret_var.inner;
17713         if (ret_var.is_owned) {
17714                 ret_ref |= 1;
17715         }
17716         return ret_ref;
17717 }
17718
17719 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
17720         LDKCounterpartyChannelTransactionParameters obj_conv;
17721         obj_conv.inner = (void*)(obj & (~1));
17722         obj_conv.is_owned = false;
17723         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
17724         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17725         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17726         CVec_u8Z_free(ret_var);
17727         return ret_arr;
17728 }
17729
17730 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
17731         LDKu8slice ser_ref;
17732         ser_ref.datalen = *((uint32_t*)ser);
17733         ser_ref.data = (int8_t*)(ser + 4);
17734         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
17735         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
17736         return (long)ret_conv;
17737 }
17738
17739 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
17740         LDKChannelTransactionParameters obj_conv;
17741         obj_conv.inner = (void*)(obj & (~1));
17742         obj_conv.is_owned = false;
17743         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
17744         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17745         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17746         CVec_u8Z_free(ret_var);
17747         return ret_arr;
17748 }
17749
17750 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
17751         LDKu8slice ser_ref;
17752         ser_ref.datalen = *((uint32_t*)ser);
17753         ser_ref.data = (int8_t*)(ser + 4);
17754         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
17755         *ret_conv = ChannelTransactionParameters_read(ser_ref);
17756         return (long)ret_conv;
17757 }
17758
17759 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
17760         LDKDirectedChannelTransactionParameters this_obj_conv;
17761         this_obj_conv.inner = (void*)(this_obj & (~1));
17762         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17763         DirectedChannelTransactionParameters_free(this_obj_conv);
17764 }
17765
17766 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
17767         LDKDirectedChannelTransactionParameters this_arg_conv;
17768         this_arg_conv.inner = (void*)(this_arg & (~1));
17769         this_arg_conv.is_owned = false;
17770         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
17771         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17772         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17773         long ret_ref = (long)ret_var.inner;
17774         if (ret_var.is_owned) {
17775                 ret_ref |= 1;
17776         }
17777         return ret_ref;
17778 }
17779
17780 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
17781         LDKDirectedChannelTransactionParameters this_arg_conv;
17782         this_arg_conv.inner = (void*)(this_arg & (~1));
17783         this_arg_conv.is_owned = false;
17784         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
17785         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17786         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17787         long ret_ref = (long)ret_var.inner;
17788         if (ret_var.is_owned) {
17789                 ret_ref |= 1;
17790         }
17791         return ret_ref;
17792 }
17793
17794 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
17795         LDKDirectedChannelTransactionParameters this_arg_conv;
17796         this_arg_conv.inner = (void*)(this_arg & (~1));
17797         this_arg_conv.is_owned = false;
17798         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
17799         return ret_val;
17800 }
17801
17802 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
17803         LDKDirectedChannelTransactionParameters this_arg_conv;
17804         this_arg_conv.inner = (void*)(this_arg & (~1));
17805         this_arg_conv.is_owned = false;
17806         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
17807         return ret_val;
17808 }
17809
17810 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
17811         LDKDirectedChannelTransactionParameters this_arg_conv;
17812         this_arg_conv.inner = (void*)(this_arg & (~1));
17813         this_arg_conv.is_owned = false;
17814         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
17815         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17816         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17817         long ret_ref = (long)ret_var.inner;
17818         if (ret_var.is_owned) {
17819                 ret_ref |= 1;
17820         }
17821         return ret_ref;
17822 }
17823
17824 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
17825         LDKHolderCommitmentTransaction this_obj_conv;
17826         this_obj_conv.inner = (void*)(this_obj & (~1));
17827         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17828         HolderCommitmentTransaction_free(this_obj_conv);
17829 }
17830
17831 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
17832         LDKHolderCommitmentTransaction this_ptr_conv;
17833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17834         this_ptr_conv.is_owned = false;
17835         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17836         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
17837         return ret_arr;
17838 }
17839
17840 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
17841         LDKHolderCommitmentTransaction this_ptr_conv;
17842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17843         this_ptr_conv.is_owned = false;
17844         LDKSignature val_ref;
17845         CHECK(*((uint32_t*)val) == 64);
17846         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17847         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
17848 }
17849
17850 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
17851         LDKHolderCommitmentTransaction this_ptr_conv;
17852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17853         this_ptr_conv.is_owned = false;
17854         LDKCVec_SignatureZ val_constr;
17855         val_constr.datalen = *((uint32_t*)val);
17856         if (val_constr.datalen > 0)
17857                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17858         else
17859                 val_constr.data = NULL;
17860         int8_tArray* val_vals = (int8_tArray*)(val + 4);
17861         for (size_t m = 0; m < val_constr.datalen; m++) {
17862                 int8_tArray val_conv_12 = val_vals[m];
17863                 LDKSignature val_conv_12_ref;
17864                 CHECK(*((uint32_t*)val_conv_12) == 64);
17865                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
17866                 val_constr.data[m] = val_conv_12_ref;
17867         }
17868         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
17869 }
17870
17871 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
17872         LDKHolderCommitmentTransaction orig_conv;
17873         orig_conv.inner = (void*)(orig & (~1));
17874         orig_conv.is_owned = false;
17875         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
17876         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17877         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17878         long ret_ref = (long)ret_var.inner;
17879         if (ret_var.is_owned) {
17880                 ret_ref |= 1;
17881         }
17882         return ret_ref;
17883 }
17884
17885 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
17886         LDKHolderCommitmentTransaction obj_conv;
17887         obj_conv.inner = (void*)(obj & (~1));
17888         obj_conv.is_owned = false;
17889         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
17890         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17891         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17892         CVec_u8Z_free(ret_var);
17893         return ret_arr;
17894 }
17895
17896 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
17897         LDKu8slice ser_ref;
17898         ser_ref.datalen = *((uint32_t*)ser);
17899         ser_ref.data = (int8_t*)(ser + 4);
17900         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
17901         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
17902         return (long)ret_conv;
17903 }
17904
17905 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) {
17906         LDKCommitmentTransaction commitment_tx_conv;
17907         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
17908         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
17909         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
17910         LDKSignature counterparty_sig_ref;
17911         CHECK(*((uint32_t*)counterparty_sig) == 64);
17912         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
17913         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
17914         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
17915         if (counterparty_htlc_sigs_constr.datalen > 0)
17916                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17917         else
17918                 counterparty_htlc_sigs_constr.data = NULL;
17919         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
17920         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
17921                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
17922                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
17923                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
17924                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
17925                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
17926         }
17927         LDKPublicKey holder_funding_key_ref;
17928         CHECK(*((uint32_t*)holder_funding_key) == 33);
17929         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
17930         LDKPublicKey counterparty_funding_key_ref;
17931         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
17932         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
17933         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
17934         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17935         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17936         long ret_ref = (long)ret_var.inner;
17937         if (ret_var.is_owned) {
17938                 ret_ref |= 1;
17939         }
17940         return ret_ref;
17941 }
17942
17943 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
17944         LDKBuiltCommitmentTransaction this_obj_conv;
17945         this_obj_conv.inner = (void*)(this_obj & (~1));
17946         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17947         BuiltCommitmentTransaction_free(this_obj_conv);
17948 }
17949
17950 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
17951         LDKBuiltCommitmentTransaction this_ptr_conv;
17952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17953         this_ptr_conv.is_owned = false;
17954         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_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         Transaction_free(ret_var);
17958         return ret_arr;
17959 }
17960
17961 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
17962         LDKBuiltCommitmentTransaction this_ptr_conv;
17963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17964         this_ptr_conv.is_owned = false;
17965         LDKTransaction val_ref;
17966         val_ref.datalen = *((uint32_t*)val);
17967         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
17968         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17969         val_ref.data_is_owned = true;
17970         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
17971 }
17972
17973 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
17974         LDKBuiltCommitmentTransaction this_ptr_conv;
17975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17976         this_ptr_conv.is_owned = false;
17977         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17978         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
17979         return ret_arr;
17980 }
17981
17982 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
17983         LDKBuiltCommitmentTransaction this_ptr_conv;
17984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17985         this_ptr_conv.is_owned = false;
17986         LDKThirtyTwoBytes val_ref;
17987         CHECK(*((uint32_t*)val) == 32);
17988         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17989         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
17990 }
17991
17992 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
17993         LDKTransaction transaction_arg_ref;
17994         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
17995         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
17996         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
17997         transaction_arg_ref.data_is_owned = true;
17998         LDKThirtyTwoBytes txid_arg_ref;
17999         CHECK(*((uint32_t*)txid_arg) == 32);
18000         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
18001         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
18002         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18003         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18004         long ret_ref = (long)ret_var.inner;
18005         if (ret_var.is_owned) {
18006                 ret_ref |= 1;
18007         }
18008         return ret_ref;
18009 }
18010
18011 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
18012         LDKBuiltCommitmentTransaction orig_conv;
18013         orig_conv.inner = (void*)(orig & (~1));
18014         orig_conv.is_owned = false;
18015         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
18016         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18017         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18018         long ret_ref = (long)ret_var.inner;
18019         if (ret_var.is_owned) {
18020                 ret_ref |= 1;
18021         }
18022         return ret_ref;
18023 }
18024
18025 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
18026         LDKBuiltCommitmentTransaction obj_conv;
18027         obj_conv.inner = (void*)(obj & (~1));
18028         obj_conv.is_owned = false;
18029         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
18030         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18031         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18032         CVec_u8Z_free(ret_var);
18033         return ret_arr;
18034 }
18035
18036 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
18037         LDKu8slice ser_ref;
18038         ser_ref.datalen = *((uint32_t*)ser);
18039         ser_ref.data = (int8_t*)(ser + 4);
18040         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
18041         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
18042         return (long)ret_conv;
18043 }
18044
18045 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
18046         LDKBuiltCommitmentTransaction this_arg_conv;
18047         this_arg_conv.inner = (void*)(this_arg & (~1));
18048         this_arg_conv.is_owned = false;
18049         LDKu8slice funding_redeemscript_ref;
18050         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
18051         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
18052         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18053         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
18054         return ret_arr;
18055 }
18056
18057 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) {
18058         LDKBuiltCommitmentTransaction this_arg_conv;
18059         this_arg_conv.inner = (void*)(this_arg & (~1));
18060         this_arg_conv.is_owned = false;
18061         unsigned char funding_key_arr[32];
18062         CHECK(*((uint32_t*)funding_key) == 32);
18063         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
18064         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
18065         LDKu8slice funding_redeemscript_ref;
18066         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
18067         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
18068         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18069         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
18070         return ret_arr;
18071 }
18072
18073 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
18074         LDKCommitmentTransaction this_obj_conv;
18075         this_obj_conv.inner = (void*)(this_obj & (~1));
18076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18077         CommitmentTransaction_free(this_obj_conv);
18078 }
18079
18080 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
18081         LDKCommitmentTransaction orig_conv;
18082         orig_conv.inner = (void*)(orig & (~1));
18083         orig_conv.is_owned = false;
18084         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
18085         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18086         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18087         long ret_ref = (long)ret_var.inner;
18088         if (ret_var.is_owned) {
18089                 ret_ref |= 1;
18090         }
18091         return ret_ref;
18092 }
18093
18094 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
18095         LDKCommitmentTransaction obj_conv;
18096         obj_conv.inner = (void*)(obj & (~1));
18097         obj_conv.is_owned = false;
18098         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
18099         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18100         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18101         CVec_u8Z_free(ret_var);
18102         return ret_arr;
18103 }
18104
18105 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
18106         LDKu8slice ser_ref;
18107         ser_ref.datalen = *((uint32_t*)ser);
18108         ser_ref.data = (int8_t*)(ser + 4);
18109         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
18110         *ret_conv = CommitmentTransaction_read(ser_ref);
18111         return (long)ret_conv;
18112 }
18113
18114 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
18115         LDKCommitmentTransaction this_arg_conv;
18116         this_arg_conv.inner = (void*)(this_arg & (~1));
18117         this_arg_conv.is_owned = false;
18118         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
18119         return ret_val;
18120 }
18121
18122 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
18123         LDKCommitmentTransaction this_arg_conv;
18124         this_arg_conv.inner = (void*)(this_arg & (~1));
18125         this_arg_conv.is_owned = false;
18126         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
18127         return ret_val;
18128 }
18129
18130 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
18131         LDKCommitmentTransaction this_arg_conv;
18132         this_arg_conv.inner = (void*)(this_arg & (~1));
18133         this_arg_conv.is_owned = false;
18134         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
18135         return ret_val;
18136 }
18137
18138 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
18139         LDKCommitmentTransaction this_arg_conv;
18140         this_arg_conv.inner = (void*)(this_arg & (~1));
18141         this_arg_conv.is_owned = false;
18142         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
18143         return ret_val;
18144 }
18145
18146 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
18147         LDKCommitmentTransaction this_arg_conv;
18148         this_arg_conv.inner = (void*)(this_arg & (~1));
18149         this_arg_conv.is_owned = false;
18150         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
18151         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18152         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18153         long ret_ref = (long)ret_var.inner;
18154         if (ret_var.is_owned) {
18155                 ret_ref |= 1;
18156         }
18157         return ret_ref;
18158 }
18159
18160 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
18161         LDKCommitmentTransaction this_arg_conv;
18162         this_arg_conv.inner = (void*)(this_arg & (~1));
18163         this_arg_conv.is_owned = false;
18164         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18165         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18166         channel_parameters_conv.is_owned = false;
18167         LDKChannelPublicKeys broadcaster_keys_conv;
18168         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18169         broadcaster_keys_conv.is_owned = false;
18170         LDKChannelPublicKeys countersignatory_keys_conv;
18171         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18172         countersignatory_keys_conv.is_owned = false;
18173         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
18174         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
18175         return (long)ret_conv;
18176 }
18177
18178 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
18179         LDKTrustedCommitmentTransaction this_obj_conv;
18180         this_obj_conv.inner = (void*)(this_obj & (~1));
18181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18182         TrustedCommitmentTransaction_free(this_obj_conv);
18183 }
18184
18185 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
18186         LDKTrustedCommitmentTransaction this_arg_conv;
18187         this_arg_conv.inner = (void*)(this_arg & (~1));
18188         this_arg_conv.is_owned = false;
18189         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18190         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
18191         return ret_arr;
18192 }
18193
18194 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
18195         LDKTrustedCommitmentTransaction this_arg_conv;
18196         this_arg_conv.inner = (void*)(this_arg & (~1));
18197         this_arg_conv.is_owned = false;
18198         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
18199         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18200         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18201         long ret_ref = (long)ret_var.inner;
18202         if (ret_var.is_owned) {
18203                 ret_ref |= 1;
18204         }
18205         return ret_ref;
18206 }
18207
18208 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
18209         LDKTrustedCommitmentTransaction this_arg_conv;
18210         this_arg_conv.inner = (void*)(this_arg & (~1));
18211         this_arg_conv.is_owned = false;
18212         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
18213         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18214         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18215         long ret_ref = (long)ret_var.inner;
18216         if (ret_var.is_owned) {
18217                 ret_ref |= 1;
18218         }
18219         return ret_ref;
18220 }
18221
18222 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
18223         LDKTrustedCommitmentTransaction this_arg_conv;
18224         this_arg_conv.inner = (void*)(this_arg & (~1));
18225         this_arg_conv.is_owned = false;
18226         unsigned char htlc_base_key_arr[32];
18227         CHECK(*((uint32_t*)htlc_base_key) == 32);
18228         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
18229         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
18230         LDKDirectedChannelTransactionParameters channel_parameters_conv;
18231         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
18232         channel_parameters_conv.is_owned = false;
18233         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
18234         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
18235         return (long)ret_conv;
18236 }
18237
18238 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) {
18239         LDKPublicKey broadcaster_payment_basepoint_ref;
18240         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
18241         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
18242         LDKPublicKey countersignatory_payment_basepoint_ref;
18243         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
18244         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
18245         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
18246         return ret_val;
18247 }
18248
18249 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
18250         LDKInitFeatures orig_conv;
18251         orig_conv.inner = (void*)(orig & (~1));
18252         orig_conv.is_owned = false;
18253         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
18254         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18255         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18256         long ret_ref = (long)ret_var.inner;
18257         if (ret_var.is_owned) {
18258                 ret_ref |= 1;
18259         }
18260         return ret_ref;
18261 }
18262
18263 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
18264         LDKNodeFeatures orig_conv;
18265         orig_conv.inner = (void*)(orig & (~1));
18266         orig_conv.is_owned = false;
18267         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
18268         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18269         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18270         long ret_ref = (long)ret_var.inner;
18271         if (ret_var.is_owned) {
18272                 ret_ref |= 1;
18273         }
18274         return ret_ref;
18275 }
18276
18277 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
18278         LDKChannelFeatures orig_conv;
18279         orig_conv.inner = (void*)(orig & (~1));
18280         orig_conv.is_owned = false;
18281         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
18282         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18283         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18284         long ret_ref = (long)ret_var.inner;
18285         if (ret_var.is_owned) {
18286                 ret_ref |= 1;
18287         }
18288         return ret_ref;
18289 }
18290
18291 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
18292         LDKInvoiceFeatures orig_conv;
18293         orig_conv.inner = (void*)(orig & (~1));
18294         orig_conv.is_owned = false;
18295         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
18296         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18297         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18298         long ret_ref = (long)ret_var.inner;
18299         if (ret_var.is_owned) {
18300                 ret_ref |= 1;
18301         }
18302         return ret_ref;
18303 }
18304
18305 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
18306         LDKInitFeatures this_obj_conv;
18307         this_obj_conv.inner = (void*)(this_obj & (~1));
18308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18309         InitFeatures_free(this_obj_conv);
18310 }
18311
18312 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
18313         LDKNodeFeatures this_obj_conv;
18314         this_obj_conv.inner = (void*)(this_obj & (~1));
18315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18316         NodeFeatures_free(this_obj_conv);
18317 }
18318
18319 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
18320         LDKChannelFeatures this_obj_conv;
18321         this_obj_conv.inner = (void*)(this_obj & (~1));
18322         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18323         ChannelFeatures_free(this_obj_conv);
18324 }
18325
18326 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
18327         LDKInvoiceFeatures this_obj_conv;
18328         this_obj_conv.inner = (void*)(this_obj & (~1));
18329         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18330         InvoiceFeatures_free(this_obj_conv);
18331 }
18332
18333 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
18334         LDKInitFeatures ret_var = InitFeatures_empty();
18335         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18336         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18337         long ret_ref = (long)ret_var.inner;
18338         if (ret_var.is_owned) {
18339                 ret_ref |= 1;
18340         }
18341         return ret_ref;
18342 }
18343
18344 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
18345         LDKInitFeatures ret_var = InitFeatures_known();
18346         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18347         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18348         long ret_ref = (long)ret_var.inner;
18349         if (ret_var.is_owned) {
18350                 ret_ref |= 1;
18351         }
18352         return ret_ref;
18353 }
18354
18355 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
18356         LDKNodeFeatures ret_var = NodeFeatures_empty();
18357         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18358         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18359         long ret_ref = (long)ret_var.inner;
18360         if (ret_var.is_owned) {
18361                 ret_ref |= 1;
18362         }
18363         return ret_ref;
18364 }
18365
18366 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
18367         LDKNodeFeatures ret_var = NodeFeatures_known();
18368         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18369         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18370         long ret_ref = (long)ret_var.inner;
18371         if (ret_var.is_owned) {
18372                 ret_ref |= 1;
18373         }
18374         return ret_ref;
18375 }
18376
18377 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
18378         LDKChannelFeatures ret_var = ChannelFeatures_empty();
18379         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18380         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18381         long ret_ref = (long)ret_var.inner;
18382         if (ret_var.is_owned) {
18383                 ret_ref |= 1;
18384         }
18385         return ret_ref;
18386 }
18387
18388 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
18389         LDKChannelFeatures ret_var = ChannelFeatures_known();
18390         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18391         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18392         long ret_ref = (long)ret_var.inner;
18393         if (ret_var.is_owned) {
18394                 ret_ref |= 1;
18395         }
18396         return ret_ref;
18397 }
18398
18399 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
18400         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
18401         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18402         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18403         long ret_ref = (long)ret_var.inner;
18404         if (ret_var.is_owned) {
18405                 ret_ref |= 1;
18406         }
18407         return ret_ref;
18408 }
18409
18410 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
18411         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
18412         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18413         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18414         long ret_ref = (long)ret_var.inner;
18415         if (ret_var.is_owned) {
18416                 ret_ref |= 1;
18417         }
18418         return ret_ref;
18419 }
18420
18421 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
18422         LDKInitFeatures obj_conv;
18423         obj_conv.inner = (void*)(obj & (~1));
18424         obj_conv.is_owned = false;
18425         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
18426         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18427         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18428         CVec_u8Z_free(ret_var);
18429         return ret_arr;
18430 }
18431
18432 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
18433         LDKNodeFeatures obj_conv;
18434         obj_conv.inner = (void*)(obj & (~1));
18435         obj_conv.is_owned = false;
18436         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
18437         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18438         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18439         CVec_u8Z_free(ret_var);
18440         return ret_arr;
18441 }
18442
18443 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
18444         LDKChannelFeatures obj_conv;
18445         obj_conv.inner = (void*)(obj & (~1));
18446         obj_conv.is_owned = false;
18447         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
18448         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18449         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18450         CVec_u8Z_free(ret_var);
18451         return ret_arr;
18452 }
18453
18454 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
18455         LDKInvoiceFeatures obj_conv;
18456         obj_conv.inner = (void*)(obj & (~1));
18457         obj_conv.is_owned = false;
18458         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
18459         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18460         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18461         CVec_u8Z_free(ret_var);
18462         return ret_arr;
18463 }
18464
18465 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
18466         LDKu8slice ser_ref;
18467         ser_ref.datalen = *((uint32_t*)ser);
18468         ser_ref.data = (int8_t*)(ser + 4);
18469         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18470         *ret_conv = InitFeatures_read(ser_ref);
18471         return (long)ret_conv;
18472 }
18473
18474 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
18475         LDKu8slice ser_ref;
18476         ser_ref.datalen = *((uint32_t*)ser);
18477         ser_ref.data = (int8_t*)(ser + 4);
18478         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18479         *ret_conv = NodeFeatures_read(ser_ref);
18480         return (long)ret_conv;
18481 }
18482
18483 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
18484         LDKu8slice ser_ref;
18485         ser_ref.datalen = *((uint32_t*)ser);
18486         ser_ref.data = (int8_t*)(ser + 4);
18487         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18488         *ret_conv = ChannelFeatures_read(ser_ref);
18489         return (long)ret_conv;
18490 }
18491
18492 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
18493         LDKu8slice ser_ref;
18494         ser_ref.datalen = *((uint32_t*)ser);
18495         ser_ref.data = (int8_t*)(ser + 4);
18496         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18497         *ret_conv = InvoiceFeatures_read(ser_ref);
18498         return (long)ret_conv;
18499 }
18500
18501 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
18502         LDKRouteHop this_obj_conv;
18503         this_obj_conv.inner = (void*)(this_obj & (~1));
18504         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18505         RouteHop_free(this_obj_conv);
18506 }
18507
18508 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
18509         LDKRouteHop this_ptr_conv;
18510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18511         this_ptr_conv.is_owned = false;
18512         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18513         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
18514         return ret_arr;
18515 }
18516
18517 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
18518         LDKRouteHop this_ptr_conv;
18519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18520         this_ptr_conv.is_owned = false;
18521         LDKPublicKey val_ref;
18522         CHECK(*((uint32_t*)val) == 33);
18523         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18524         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
18525 }
18526
18527 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
18528         LDKRouteHop this_ptr_conv;
18529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18530         this_ptr_conv.is_owned = false;
18531         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
18532         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18533         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18534         long ret_ref = (long)ret_var.inner;
18535         if (ret_var.is_owned) {
18536                 ret_ref |= 1;
18537         }
18538         return ret_ref;
18539 }
18540
18541 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
18542         LDKRouteHop this_ptr_conv;
18543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18544         this_ptr_conv.is_owned = false;
18545         LDKNodeFeatures val_conv;
18546         val_conv.inner = (void*)(val & (~1));
18547         val_conv.is_owned = (val & 1) || (val == 0);
18548         val_conv = NodeFeatures_clone(&val_conv);
18549         RouteHop_set_node_features(&this_ptr_conv, val_conv);
18550 }
18551
18552 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
18553         LDKRouteHop this_ptr_conv;
18554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18555         this_ptr_conv.is_owned = false;
18556         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
18557         return ret_val;
18558 }
18559
18560 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18561         LDKRouteHop this_ptr_conv;
18562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18563         this_ptr_conv.is_owned = false;
18564         RouteHop_set_short_channel_id(&this_ptr_conv, val);
18565 }
18566
18567 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
18568         LDKRouteHop this_ptr_conv;
18569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18570         this_ptr_conv.is_owned = false;
18571         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
18572         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18573         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18574         long ret_ref = (long)ret_var.inner;
18575         if (ret_var.is_owned) {
18576                 ret_ref |= 1;
18577         }
18578         return ret_ref;
18579 }
18580
18581 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
18582         LDKRouteHop this_ptr_conv;
18583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18584         this_ptr_conv.is_owned = false;
18585         LDKChannelFeatures val_conv;
18586         val_conv.inner = (void*)(val & (~1));
18587         val_conv.is_owned = (val & 1) || (val == 0);
18588         val_conv = ChannelFeatures_clone(&val_conv);
18589         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
18590 }
18591
18592 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
18593         LDKRouteHop this_ptr_conv;
18594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18595         this_ptr_conv.is_owned = false;
18596         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
18597         return ret_val;
18598 }
18599
18600 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
18601         LDKRouteHop this_ptr_conv;
18602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18603         this_ptr_conv.is_owned = false;
18604         RouteHop_set_fee_msat(&this_ptr_conv, val);
18605 }
18606
18607 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
18608         LDKRouteHop this_ptr_conv;
18609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18610         this_ptr_conv.is_owned = false;
18611         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
18612         return ret_val;
18613 }
18614
18615 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
18616         LDKRouteHop this_ptr_conv;
18617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18618         this_ptr_conv.is_owned = false;
18619         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
18620 }
18621
18622 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) {
18623         LDKPublicKey pubkey_arg_ref;
18624         CHECK(*((uint32_t*)pubkey_arg) == 33);
18625         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
18626         LDKNodeFeatures node_features_arg_conv;
18627         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
18628         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
18629         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
18630         LDKChannelFeatures channel_features_arg_conv;
18631         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
18632         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
18633         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
18634         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);
18635         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18636         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18637         long ret_ref = (long)ret_var.inner;
18638         if (ret_var.is_owned) {
18639                 ret_ref |= 1;
18640         }
18641         return ret_ref;
18642 }
18643
18644 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
18645         LDKRouteHop orig_conv;
18646         orig_conv.inner = (void*)(orig & (~1));
18647         orig_conv.is_owned = false;
18648         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
18649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18651         long ret_ref = (long)ret_var.inner;
18652         if (ret_var.is_owned) {
18653                 ret_ref |= 1;
18654         }
18655         return ret_ref;
18656 }
18657
18658 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
18659         LDKRoute this_obj_conv;
18660         this_obj_conv.inner = (void*)(this_obj & (~1));
18661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18662         Route_free(this_obj_conv);
18663 }
18664
18665 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
18666         LDKRoute this_ptr_conv;
18667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18668         this_ptr_conv.is_owned = false;
18669         LDKCVec_CVec_RouteHopZZ val_constr;
18670         val_constr.datalen = *((uint32_t*)val);
18671         if (val_constr.datalen > 0)
18672                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18673         else
18674                 val_constr.data = NULL;
18675         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
18676         for (size_t m = 0; m < val_constr.datalen; m++) {
18677                 uint32_tArray val_conv_12 = val_vals[m];
18678                 LDKCVec_RouteHopZ val_conv_12_constr;
18679                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
18680                 if (val_conv_12_constr.datalen > 0)
18681                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18682                 else
18683                         val_conv_12_constr.data = NULL;
18684                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
18685                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
18686                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
18687                         LDKRouteHop val_conv_12_conv_10_conv;
18688                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
18689                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
18690                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
18691                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
18692                 }
18693                 val_constr.data[m] = val_conv_12_constr;
18694         }
18695         Route_set_paths(&this_ptr_conv, val_constr);
18696 }
18697
18698 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
18699         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
18700         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
18701         if (paths_arg_constr.datalen > 0)
18702                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
18703         else
18704                 paths_arg_constr.data = NULL;
18705         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
18706         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
18707                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
18708                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
18709                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
18710                 if (paths_arg_conv_12_constr.datalen > 0)
18711                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
18712                 else
18713                         paths_arg_conv_12_constr.data = NULL;
18714                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
18715                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
18716                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
18717                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
18718                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
18719                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
18720                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
18721                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
18722                 }
18723                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
18724         }
18725         LDKRoute ret_var = Route_new(paths_arg_constr);
18726         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18727         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18728         long ret_ref = (long)ret_var.inner;
18729         if (ret_var.is_owned) {
18730                 ret_ref |= 1;
18731         }
18732         return ret_ref;
18733 }
18734
18735 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
18736         LDKRoute orig_conv;
18737         orig_conv.inner = (void*)(orig & (~1));
18738         orig_conv.is_owned = false;
18739         LDKRoute ret_var = Route_clone(&orig_conv);
18740         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18741         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18742         long ret_ref = (long)ret_var.inner;
18743         if (ret_var.is_owned) {
18744                 ret_ref |= 1;
18745         }
18746         return ret_ref;
18747 }
18748
18749 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
18750         LDKRoute obj_conv;
18751         obj_conv.inner = (void*)(obj & (~1));
18752         obj_conv.is_owned = false;
18753         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
18754         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18755         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18756         CVec_u8Z_free(ret_var);
18757         return ret_arr;
18758 }
18759
18760 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
18761         LDKu8slice ser_ref;
18762         ser_ref.datalen = *((uint32_t*)ser);
18763         ser_ref.data = (int8_t*)(ser + 4);
18764         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18765         *ret_conv = Route_read(ser_ref);
18766         return (long)ret_conv;
18767 }
18768
18769 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
18770         LDKRouteHint this_obj_conv;
18771         this_obj_conv.inner = (void*)(this_obj & (~1));
18772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18773         RouteHint_free(this_obj_conv);
18774 }
18775
18776 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
18777         LDKRouteHint this_ptr_conv;
18778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18779         this_ptr_conv.is_owned = false;
18780         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18781         memcpy((uint8_t*)(ret_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
18782         return ret_arr;
18783 }
18784
18785 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
18786         LDKRouteHint this_ptr_conv;
18787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18788         this_ptr_conv.is_owned = false;
18789         LDKPublicKey val_ref;
18790         CHECK(*((uint32_t*)val) == 33);
18791         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18792         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
18793 }
18794
18795 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
18796         LDKRouteHint this_ptr_conv;
18797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18798         this_ptr_conv.is_owned = false;
18799         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
18800         return ret_val;
18801 }
18802
18803 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18804         LDKRouteHint this_ptr_conv;
18805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18806         this_ptr_conv.is_owned = false;
18807         RouteHint_set_short_channel_id(&this_ptr_conv, val);
18808 }
18809
18810 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
18811         LDKRouteHint this_ptr_conv;
18812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18813         this_ptr_conv.is_owned = false;
18814         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
18815         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18816         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18817         long ret_ref = (long)ret_var.inner;
18818         if (ret_var.is_owned) {
18819                 ret_ref |= 1;
18820         }
18821         return ret_ref;
18822 }
18823
18824 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
18825         LDKRouteHint this_ptr_conv;
18826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18827         this_ptr_conv.is_owned = false;
18828         LDKRoutingFees val_conv;
18829         val_conv.inner = (void*)(val & (~1));
18830         val_conv.is_owned = (val & 1) || (val == 0);
18831         val_conv = RoutingFees_clone(&val_conv);
18832         RouteHint_set_fees(&this_ptr_conv, val_conv);
18833 }
18834
18835 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
18836         LDKRouteHint this_ptr_conv;
18837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18838         this_ptr_conv.is_owned = false;
18839         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
18840         return ret_val;
18841 }
18842
18843 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18844         LDKRouteHint this_ptr_conv;
18845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18846         this_ptr_conv.is_owned = false;
18847         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
18848 }
18849
18850 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_minimum_msat(uint32_t this_ptr) {
18851         LDKRouteHint this_ptr_conv;
18852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18853         this_ptr_conv.is_owned = false;
18854         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18855         *ret_copy = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
18856         long ret_ref = (long)ret_copy;
18857         return ret_ref;
18858 }
18859
18860 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
18861         LDKRouteHint this_ptr_conv;
18862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18863         this_ptr_conv.is_owned = false;
18864         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18865         FREE((void*)val);
18866         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
18867 }
18868
18869 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_maximum_msat(uint32_t this_ptr) {
18870         LDKRouteHint this_ptr_conv;
18871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18872         this_ptr_conv.is_owned = false;
18873         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
18874         *ret_copy = RouteHint_get_htlc_maximum_msat(&this_ptr_conv);
18875         long ret_ref = (long)ret_copy;
18876         return ret_ref;
18877 }
18878
18879 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
18880         LDKRouteHint this_ptr_conv;
18881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18882         this_ptr_conv.is_owned = false;
18883         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
18884         FREE((void*)val);
18885         RouteHint_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
18886 }
18887
18888 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) {
18889         LDKPublicKey src_node_id_arg_ref;
18890         CHECK(*((uint32_t*)src_node_id_arg) == 33);
18891         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
18892         LDKRoutingFees fees_arg_conv;
18893         fees_arg_conv.inner = (void*)(fees_arg & (~1));
18894         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
18895         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
18896         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
18897         FREE((void*)htlc_minimum_msat_arg);
18898         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
18899         FREE((void*)htlc_maximum_msat_arg);
18900         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);
18901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18903         long ret_ref = (long)ret_var.inner;
18904         if (ret_var.is_owned) {
18905                 ret_ref |= 1;
18906         }
18907         return ret_ref;
18908 }
18909
18910 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
18911         LDKRouteHint orig_conv;
18912         orig_conv.inner = (void*)(orig & (~1));
18913         orig_conv.is_owned = false;
18914         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
18915         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18916         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18917         long ret_ref = (long)ret_var.inner;
18918         if (ret_var.is_owned) {
18919                 ret_ref |= 1;
18920         }
18921         return ret_ref;
18922 }
18923
18924 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) {
18925         LDKPublicKey our_node_id_ref;
18926         CHECK(*((uint32_t*)our_node_id) == 33);
18927         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
18928         LDKNetworkGraph network_conv;
18929         network_conv.inner = (void*)(network & (~1));
18930         network_conv.is_owned = false;
18931         LDKPublicKey payee_ref;
18932         CHECK(*((uint32_t*)payee) == 33);
18933         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
18934         LDKInvoiceFeatures payee_features_conv;
18935         payee_features_conv.inner = (void*)(payee_features & (~1));
18936         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
18937         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
18938         LDKCVec_ChannelDetailsZ first_hops_constr;
18939         first_hops_constr.datalen = *((uint32_t*)first_hops);
18940         if (first_hops_constr.datalen > 0)
18941                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18942         else
18943                 first_hops_constr.data = NULL;
18944         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
18945         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
18946                 uint32_t first_hops_conv_16 = first_hops_vals[q];
18947                 LDKChannelDetails first_hops_conv_16_conv;
18948                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
18949                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
18950                 first_hops_constr.data[q] = first_hops_conv_16_conv;
18951         }
18952         LDKCVec_RouteHintZ last_hops_constr;
18953         last_hops_constr.datalen = *((uint32_t*)last_hops);
18954         if (last_hops_constr.datalen > 0)
18955                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18956         else
18957                 last_hops_constr.data = NULL;
18958         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
18959         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
18960                 uint32_t last_hops_conv_11 = last_hops_vals[l];
18961                 LDKRouteHint last_hops_conv_11_conv;
18962                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
18963                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
18964                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
18965                 last_hops_constr.data[l] = last_hops_conv_11_conv;
18966         }
18967         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18968         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
18969         *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);
18970         FREE(first_hops_constr.data);
18971         return (long)ret_conv;
18972 }
18973
18974 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
18975         LDKNetworkGraph this_obj_conv;
18976         this_obj_conv.inner = (void*)(this_obj & (~1));
18977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18978         NetworkGraph_free(this_obj_conv);
18979 }
18980
18981 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
18982         LDKNetworkGraph orig_conv;
18983         orig_conv.inner = (void*)(orig & (~1));
18984         orig_conv.is_owned = false;
18985         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
18986         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18987         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18988         long ret_ref = (long)ret_var.inner;
18989         if (ret_var.is_owned) {
18990                 ret_ref |= 1;
18991         }
18992         return ret_ref;
18993 }
18994
18995 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
18996         LDKLockedNetworkGraph this_obj_conv;
18997         this_obj_conv.inner = (void*)(this_obj & (~1));
18998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18999         LockedNetworkGraph_free(this_obj_conv);
19000 }
19001
19002 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
19003         LDKNetGraphMsgHandler this_obj_conv;
19004         this_obj_conv.inner = (void*)(this_obj & (~1));
19005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19006         NetGraphMsgHandler_free(this_obj_conv);
19007 }
19008
19009 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
19010         LDKThirtyTwoBytes genesis_hash_ref;
19011         CHECK(*((uint32_t*)genesis_hash) == 32);
19012         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
19013         LDKAccess *chain_access_conv_ptr = NULL;
19014         if (chain_access != 0) {
19015                 LDKAccess chain_access_conv;
19016                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19017                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19018                 *chain_access_conv_ptr = chain_access_conv;
19019         }
19020         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19021         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
19022         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19023         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19024         long ret_ref = (long)ret_var.inner;
19025         if (ret_var.is_owned) {
19026                 ret_ref |= 1;
19027         }
19028         return ret_ref;
19029 }
19030
19031 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
19032         LDKAccess *chain_access_conv_ptr = NULL;
19033         if (chain_access != 0) {
19034                 LDKAccess chain_access_conv;
19035                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19036                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19037                 *chain_access_conv_ptr = chain_access_conv;
19038         }
19039         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
19040         LDKNetworkGraph network_graph_conv;
19041         network_graph_conv.inner = (void*)(network_graph & (~1));
19042         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
19043         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
19044         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
19045         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19046         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19047         long ret_ref = (long)ret_var.inner;
19048         if (ret_var.is_owned) {
19049                 ret_ref |= 1;
19050         }
19051         return ret_ref;
19052 }
19053
19054 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
19055         LDKNetGraphMsgHandler this_arg_conv;
19056         this_arg_conv.inner = (void*)(this_arg & (~1));
19057         this_arg_conv.is_owned = false;
19058         LDKAccess *chain_access_conv_ptr = NULL;
19059         if (chain_access != 0) {
19060                 LDKAccess chain_access_conv;
19061                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19062                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19063                 *chain_access_conv_ptr = chain_access_conv;
19064         }
19065         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
19066 }
19067
19068 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
19069         LDKNetGraphMsgHandler this_arg_conv;
19070         this_arg_conv.inner = (void*)(this_arg & (~1));
19071         this_arg_conv.is_owned = false;
19072         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
19073         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19074         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19075         long ret_ref = (long)ret_var.inner;
19076         if (ret_var.is_owned) {
19077                 ret_ref |= 1;
19078         }
19079         return ret_ref;
19080 }
19081
19082 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
19083         LDKLockedNetworkGraph this_arg_conv;
19084         this_arg_conv.inner = (void*)(this_arg & (~1));
19085         this_arg_conv.is_owned = false;
19086         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
19087         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19088         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19089         long ret_ref = (long)ret_var.inner;
19090         if (ret_var.is_owned) {
19091                 ret_ref |= 1;
19092         }
19093         return ret_ref;
19094 }
19095
19096 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
19097         LDKNetGraphMsgHandler this_arg_conv;
19098         this_arg_conv.inner = (void*)(this_arg & (~1));
19099         this_arg_conv.is_owned = false;
19100         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
19101         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
19102         return (long)ret;
19103 }
19104
19105 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
19106         LDKNetGraphMsgHandler this_arg_conv;
19107         this_arg_conv.inner = (void*)(this_arg & (~1));
19108         this_arg_conv.is_owned = false;
19109         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
19110         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
19111         return (long)ret;
19112 }
19113
19114 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
19115         LDKDirectionalChannelInfo this_obj_conv;
19116         this_obj_conv.inner = (void*)(this_obj & (~1));
19117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19118         DirectionalChannelInfo_free(this_obj_conv);
19119 }
19120
19121 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
19122         LDKDirectionalChannelInfo this_ptr_conv;
19123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19124         this_ptr_conv.is_owned = false;
19125         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
19126         return ret_val;
19127 }
19128
19129 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
19130         LDKDirectionalChannelInfo this_ptr_conv;
19131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19132         this_ptr_conv.is_owned = false;
19133         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
19134 }
19135
19136 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
19137         LDKDirectionalChannelInfo this_ptr_conv;
19138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19139         this_ptr_conv.is_owned = false;
19140         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
19141         return ret_val;
19142 }
19143
19144 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
19145         LDKDirectionalChannelInfo this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
19149 }
19150
19151 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
19152         LDKDirectionalChannelInfo this_ptr_conv;
19153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19154         this_ptr_conv.is_owned = false;
19155         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
19156         return ret_val;
19157 }
19158
19159 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
19160         LDKDirectionalChannelInfo this_ptr_conv;
19161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19162         this_ptr_conv.is_owned = false;
19163         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
19164 }
19165
19166 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
19167         LDKDirectionalChannelInfo this_ptr_conv;
19168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19169         this_ptr_conv.is_owned = false;
19170         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
19171         return ret_val;
19172 }
19173
19174 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
19175         LDKDirectionalChannelInfo this_ptr_conv;
19176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19177         this_ptr_conv.is_owned = false;
19178         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
19179 }
19180
19181 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
19182         LDKDirectionalChannelInfo this_ptr_conv;
19183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19184         this_ptr_conv.is_owned = false;
19185         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19186         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
19187         long ret_ref = (long)ret_copy;
19188         return ret_ref;
19189 }
19190
19191 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
19192         LDKDirectionalChannelInfo this_ptr_conv;
19193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19194         this_ptr_conv.is_owned = false;
19195         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19196         FREE((void*)val);
19197         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
19198 }
19199
19200 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
19201         LDKDirectionalChannelInfo this_ptr_conv;
19202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19203         this_ptr_conv.is_owned = false;
19204         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
19205         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19206         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19207         long ret_ref = (long)ret_var.inner;
19208         if (ret_var.is_owned) {
19209                 ret_ref |= 1;
19210         }
19211         return ret_ref;
19212 }
19213
19214 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
19215         LDKDirectionalChannelInfo this_ptr_conv;
19216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19217         this_ptr_conv.is_owned = false;
19218         LDKRoutingFees val_conv;
19219         val_conv.inner = (void*)(val & (~1));
19220         val_conv.is_owned = (val & 1) || (val == 0);
19221         val_conv = RoutingFees_clone(&val_conv);
19222         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
19223 }
19224
19225 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
19226         LDKDirectionalChannelInfo this_ptr_conv;
19227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19228         this_ptr_conv.is_owned = false;
19229         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
19230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19232         long ret_ref = (long)ret_var.inner;
19233         if (ret_var.is_owned) {
19234                 ret_ref |= 1;
19235         }
19236         return ret_ref;
19237 }
19238
19239 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
19240         LDKDirectionalChannelInfo this_ptr_conv;
19241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19242         this_ptr_conv.is_owned = false;
19243         LDKChannelUpdate val_conv;
19244         val_conv.inner = (void*)(val & (~1));
19245         val_conv.is_owned = (val & 1) || (val == 0);
19246         val_conv = ChannelUpdate_clone(&val_conv);
19247         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
19248 }
19249
19250 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) {
19251         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
19252         FREE((void*)htlc_maximum_msat_arg);
19253         LDKRoutingFees fees_arg_conv;
19254         fees_arg_conv.inner = (void*)(fees_arg & (~1));
19255         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
19256         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
19257         LDKChannelUpdate last_update_message_arg_conv;
19258         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
19259         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
19260         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
19261         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);
19262         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19263         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19264         long ret_ref = (long)ret_var.inner;
19265         if (ret_var.is_owned) {
19266                 ret_ref |= 1;
19267         }
19268         return ret_ref;
19269 }
19270
19271 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
19272         LDKDirectionalChannelInfo orig_conv;
19273         orig_conv.inner = (void*)(orig & (~1));
19274         orig_conv.is_owned = false;
19275         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
19276         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19277         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19278         long ret_ref = (long)ret_var.inner;
19279         if (ret_var.is_owned) {
19280                 ret_ref |= 1;
19281         }
19282         return ret_ref;
19283 }
19284
19285 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
19286         LDKDirectionalChannelInfo obj_conv;
19287         obj_conv.inner = (void*)(obj & (~1));
19288         obj_conv.is_owned = false;
19289         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
19290         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19291         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19292         CVec_u8Z_free(ret_var);
19293         return ret_arr;
19294 }
19295
19296 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
19297         LDKu8slice ser_ref;
19298         ser_ref.datalen = *((uint32_t*)ser);
19299         ser_ref.data = (int8_t*)(ser + 4);
19300         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19301         *ret_conv = DirectionalChannelInfo_read(ser_ref);
19302         return (long)ret_conv;
19303 }
19304
19305 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
19306         LDKChannelInfo this_obj_conv;
19307         this_obj_conv.inner = (void*)(this_obj & (~1));
19308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19309         ChannelInfo_free(this_obj_conv);
19310 }
19311
19312 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
19313         LDKChannelInfo this_ptr_conv;
19314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19315         this_ptr_conv.is_owned = false;
19316         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
19317         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19318         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19319         long ret_ref = (long)ret_var.inner;
19320         if (ret_var.is_owned) {
19321                 ret_ref |= 1;
19322         }
19323         return ret_ref;
19324 }
19325
19326 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
19327         LDKChannelInfo this_ptr_conv;
19328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19329         this_ptr_conv.is_owned = false;
19330         LDKChannelFeatures val_conv;
19331         val_conv.inner = (void*)(val & (~1));
19332         val_conv.is_owned = (val & 1) || (val == 0);
19333         val_conv = ChannelFeatures_clone(&val_conv);
19334         ChannelInfo_set_features(&this_ptr_conv, val_conv);
19335 }
19336
19337 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
19338         LDKChannelInfo this_ptr_conv;
19339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19340         this_ptr_conv.is_owned = false;
19341         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19342         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
19343         return ret_arr;
19344 }
19345
19346 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
19347         LDKChannelInfo this_ptr_conv;
19348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19349         this_ptr_conv.is_owned = false;
19350         LDKPublicKey val_ref;
19351         CHECK(*((uint32_t*)val) == 33);
19352         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19353         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
19354 }
19355
19356 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
19357         LDKChannelInfo this_ptr_conv;
19358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19359         this_ptr_conv.is_owned = false;
19360         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
19361         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19362         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19363         long ret_ref = (long)ret_var.inner;
19364         if (ret_var.is_owned) {
19365                 ret_ref |= 1;
19366         }
19367         return ret_ref;
19368 }
19369
19370 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
19371         LDKChannelInfo this_ptr_conv;
19372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19373         this_ptr_conv.is_owned = false;
19374         LDKDirectionalChannelInfo val_conv;
19375         val_conv.inner = (void*)(val & (~1));
19376         val_conv.is_owned = (val & 1) || (val == 0);
19377         val_conv = DirectionalChannelInfo_clone(&val_conv);
19378         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
19379 }
19380
19381 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
19382         LDKChannelInfo this_ptr_conv;
19383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19384         this_ptr_conv.is_owned = false;
19385         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19386         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
19387         return ret_arr;
19388 }
19389
19390 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
19391         LDKChannelInfo this_ptr_conv;
19392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19393         this_ptr_conv.is_owned = false;
19394         LDKPublicKey val_ref;
19395         CHECK(*((uint32_t*)val) == 33);
19396         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19397         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
19398 }
19399
19400 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
19401         LDKChannelInfo this_ptr_conv;
19402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19403         this_ptr_conv.is_owned = false;
19404         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
19405         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19406         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19407         long ret_ref = (long)ret_var.inner;
19408         if (ret_var.is_owned) {
19409                 ret_ref |= 1;
19410         }
19411         return ret_ref;
19412 }
19413
19414 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
19415         LDKChannelInfo this_ptr_conv;
19416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19417         this_ptr_conv.is_owned = false;
19418         LDKDirectionalChannelInfo val_conv;
19419         val_conv.inner = (void*)(val & (~1));
19420         val_conv.is_owned = (val & 1) || (val == 0);
19421         val_conv = DirectionalChannelInfo_clone(&val_conv);
19422         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
19423 }
19424
19425 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
19426         LDKChannelInfo this_ptr_conv;
19427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19428         this_ptr_conv.is_owned = false;
19429         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
19430         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
19431         long ret_ref = (long)ret_copy;
19432         return ret_ref;
19433 }
19434
19435 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
19436         LDKChannelInfo this_ptr_conv;
19437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19438         this_ptr_conv.is_owned = false;
19439         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
19440         FREE((void*)val);
19441         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
19442 }
19443
19444 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
19445         LDKChannelInfo this_ptr_conv;
19446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19447         this_ptr_conv.is_owned = false;
19448         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
19449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19451         long ret_ref = (long)ret_var.inner;
19452         if (ret_var.is_owned) {
19453                 ret_ref |= 1;
19454         }
19455         return ret_ref;
19456 }
19457
19458 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
19459         LDKChannelInfo this_ptr_conv;
19460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19461         this_ptr_conv.is_owned = false;
19462         LDKChannelAnnouncement val_conv;
19463         val_conv.inner = (void*)(val & (~1));
19464         val_conv.is_owned = (val & 1) || (val == 0);
19465         val_conv = ChannelAnnouncement_clone(&val_conv);
19466         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
19467 }
19468
19469 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) {
19470         LDKChannelFeatures features_arg_conv;
19471         features_arg_conv.inner = (void*)(features_arg & (~1));
19472         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19473         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
19474         LDKPublicKey node_one_arg_ref;
19475         CHECK(*((uint32_t*)node_one_arg) == 33);
19476         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
19477         LDKDirectionalChannelInfo one_to_two_arg_conv;
19478         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
19479         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
19480         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
19481         LDKPublicKey node_two_arg_ref;
19482         CHECK(*((uint32_t*)node_two_arg) == 33);
19483         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
19484         LDKDirectionalChannelInfo two_to_one_arg_conv;
19485         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
19486         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
19487         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
19488         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
19489         FREE((void*)capacity_sats_arg);
19490         LDKChannelAnnouncement announcement_message_arg_conv;
19491         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19492         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19493         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
19494         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);
19495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19497         long ret_ref = (long)ret_var.inner;
19498         if (ret_var.is_owned) {
19499                 ret_ref |= 1;
19500         }
19501         return ret_ref;
19502 }
19503
19504 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
19505         LDKChannelInfo orig_conv;
19506         orig_conv.inner = (void*)(orig & (~1));
19507         orig_conv.is_owned = false;
19508         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
19509         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19510         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19511         long ret_ref = (long)ret_var.inner;
19512         if (ret_var.is_owned) {
19513                 ret_ref |= 1;
19514         }
19515         return ret_ref;
19516 }
19517
19518 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
19519         LDKChannelInfo obj_conv;
19520         obj_conv.inner = (void*)(obj & (~1));
19521         obj_conv.is_owned = false;
19522         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
19523         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19524         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19525         CVec_u8Z_free(ret_var);
19526         return ret_arr;
19527 }
19528
19529 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
19530         LDKu8slice ser_ref;
19531         ser_ref.datalen = *((uint32_t*)ser);
19532         ser_ref.data = (int8_t*)(ser + 4);
19533         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19534         *ret_conv = ChannelInfo_read(ser_ref);
19535         return (long)ret_conv;
19536 }
19537
19538 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
19539         LDKRoutingFees this_obj_conv;
19540         this_obj_conv.inner = (void*)(this_obj & (~1));
19541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19542         RoutingFees_free(this_obj_conv);
19543 }
19544
19545 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
19546         LDKRoutingFees this_ptr_conv;
19547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19548         this_ptr_conv.is_owned = false;
19549         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
19550         return ret_val;
19551 }
19552
19553 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
19554         LDKRoutingFees this_ptr_conv;
19555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19556         this_ptr_conv.is_owned = false;
19557         RoutingFees_set_base_msat(&this_ptr_conv, val);
19558 }
19559
19560 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
19561         LDKRoutingFees this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
19565         return ret_val;
19566 }
19567
19568 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
19569         LDKRoutingFees this_ptr_conv;
19570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19571         this_ptr_conv.is_owned = false;
19572         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
19573 }
19574
19575 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
19576         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
19577         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19578         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19579         long ret_ref = (long)ret_var.inner;
19580         if (ret_var.is_owned) {
19581                 ret_ref |= 1;
19582         }
19583         return ret_ref;
19584 }
19585
19586 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
19587         LDKRoutingFees orig_conv;
19588         orig_conv.inner = (void*)(orig & (~1));
19589         orig_conv.is_owned = false;
19590         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
19591         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19592         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19593         long ret_ref = (long)ret_var.inner;
19594         if (ret_var.is_owned) {
19595                 ret_ref |= 1;
19596         }
19597         return ret_ref;
19598 }
19599
19600 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
19601         LDKu8slice ser_ref;
19602         ser_ref.datalen = *((uint32_t*)ser);
19603         ser_ref.data = (int8_t*)(ser + 4);
19604         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19605         *ret_conv = RoutingFees_read(ser_ref);
19606         return (long)ret_conv;
19607 }
19608
19609 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
19610         LDKRoutingFees obj_conv;
19611         obj_conv.inner = (void*)(obj & (~1));
19612         obj_conv.is_owned = false;
19613         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
19614         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19615         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19616         CVec_u8Z_free(ret_var);
19617         return ret_arr;
19618 }
19619
19620 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
19621         LDKNodeAnnouncementInfo this_obj_conv;
19622         this_obj_conv.inner = (void*)(this_obj & (~1));
19623         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19624         NodeAnnouncementInfo_free(this_obj_conv);
19625 }
19626
19627 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
19628         LDKNodeAnnouncementInfo this_ptr_conv;
19629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19630         this_ptr_conv.is_owned = false;
19631         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
19632         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19633         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19634         long ret_ref = (long)ret_var.inner;
19635         if (ret_var.is_owned) {
19636                 ret_ref |= 1;
19637         }
19638         return ret_ref;
19639 }
19640
19641 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
19642         LDKNodeAnnouncementInfo this_ptr_conv;
19643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19644         this_ptr_conv.is_owned = false;
19645         LDKNodeFeatures val_conv;
19646         val_conv.inner = (void*)(val & (~1));
19647         val_conv.is_owned = (val & 1) || (val == 0);
19648         val_conv = NodeFeatures_clone(&val_conv);
19649         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
19650 }
19651
19652 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
19653         LDKNodeAnnouncementInfo this_ptr_conv;
19654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19655         this_ptr_conv.is_owned = false;
19656         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
19657         return ret_val;
19658 }
19659
19660 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
19661         LDKNodeAnnouncementInfo this_ptr_conv;
19662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19663         this_ptr_conv.is_owned = false;
19664         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
19665 }
19666
19667 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
19668         LDKNodeAnnouncementInfo this_ptr_conv;
19669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19670         this_ptr_conv.is_owned = false;
19671         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
19672         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
19673         return ret_arr;
19674 }
19675
19676 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
19677         LDKNodeAnnouncementInfo this_ptr_conv;
19678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19679         this_ptr_conv.is_owned = false;
19680         LDKThreeBytes val_ref;
19681         CHECK(*((uint32_t*)val) == 3);
19682         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
19683         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
19684 }
19685
19686 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
19687         LDKNodeAnnouncementInfo this_ptr_conv;
19688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19689         this_ptr_conv.is_owned = false;
19690         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19691         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
19692         return ret_arr;
19693 }
19694
19695 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
19696         LDKNodeAnnouncementInfo this_ptr_conv;
19697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19698         this_ptr_conv.is_owned = false;
19699         LDKThirtyTwoBytes val_ref;
19700         CHECK(*((uint32_t*)val) == 32);
19701         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19702         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
19703 }
19704
19705 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
19706         LDKNodeAnnouncementInfo this_ptr_conv;
19707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19708         this_ptr_conv.is_owned = false;
19709         LDKCVec_NetAddressZ val_constr;
19710         val_constr.datalen = *((uint32_t*)val);
19711         if (val_constr.datalen > 0)
19712                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19713         else
19714                 val_constr.data = NULL;
19715         uint32_t* val_vals = (uint32_t*)(val + 4);
19716         for (size_t m = 0; m < val_constr.datalen; m++) {
19717                 uint32_t val_conv_12 = val_vals[m];
19718                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19719                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19720                 val_constr.data[m] = val_conv_12_conv;
19721         }
19722         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
19723 }
19724
19725 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
19726         LDKNodeAnnouncementInfo this_ptr_conv;
19727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19728         this_ptr_conv.is_owned = false;
19729         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
19730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19732         long ret_ref = (long)ret_var.inner;
19733         if (ret_var.is_owned) {
19734                 ret_ref |= 1;
19735         }
19736         return ret_ref;
19737 }
19738
19739 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
19740         LDKNodeAnnouncementInfo this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         LDKNodeAnnouncement val_conv;
19744         val_conv.inner = (void*)(val & (~1));
19745         val_conv.is_owned = (val & 1) || (val == 0);
19746         val_conv = NodeAnnouncement_clone(&val_conv);
19747         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
19748 }
19749
19750 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) {
19751         LDKNodeFeatures features_arg_conv;
19752         features_arg_conv.inner = (void*)(features_arg & (~1));
19753         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
19754         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
19755         LDKThreeBytes rgb_arg_ref;
19756         CHECK(*((uint32_t*)rgb_arg) == 3);
19757         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
19758         LDKThirtyTwoBytes alias_arg_ref;
19759         CHECK(*((uint32_t*)alias_arg) == 32);
19760         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
19761         LDKCVec_NetAddressZ addresses_arg_constr;
19762         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
19763         if (addresses_arg_constr.datalen > 0)
19764                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19765         else
19766                 addresses_arg_constr.data = NULL;
19767         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
19768         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
19769                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
19770                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
19771                 FREE((void*)addresses_arg_conv_12);
19772                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
19773         }
19774         LDKNodeAnnouncement announcement_message_arg_conv;
19775         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
19776         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
19777         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
19778         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
19779         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19780         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19781         long ret_ref = (long)ret_var.inner;
19782         if (ret_var.is_owned) {
19783                 ret_ref |= 1;
19784         }
19785         return ret_ref;
19786 }
19787
19788 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
19789         LDKNodeAnnouncementInfo orig_conv;
19790         orig_conv.inner = (void*)(orig & (~1));
19791         orig_conv.is_owned = false;
19792         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
19793         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19794         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19795         long ret_ref = (long)ret_var.inner;
19796         if (ret_var.is_owned) {
19797                 ret_ref |= 1;
19798         }
19799         return ret_ref;
19800 }
19801
19802 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
19803         LDKNodeAnnouncementInfo obj_conv;
19804         obj_conv.inner = (void*)(obj & (~1));
19805         obj_conv.is_owned = false;
19806         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
19807         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19808         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19809         CVec_u8Z_free(ret_var);
19810         return ret_arr;
19811 }
19812
19813 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
19814         LDKu8slice ser_ref;
19815         ser_ref.datalen = *((uint32_t*)ser);
19816         ser_ref.data = (int8_t*)(ser + 4);
19817         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19818         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
19819         return (long)ret_conv;
19820 }
19821
19822 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
19823         LDKNodeInfo this_obj_conv;
19824         this_obj_conv.inner = (void*)(this_obj & (~1));
19825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19826         NodeInfo_free(this_obj_conv);
19827 }
19828
19829 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
19830         LDKNodeInfo this_ptr_conv;
19831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19832         this_ptr_conv.is_owned = false;
19833         LDKCVec_u64Z val_constr;
19834         val_constr.datalen = *((uint32_t*)val);
19835         if (val_constr.datalen > 0)
19836                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19837         else
19838                 val_constr.data = NULL;
19839         int64_t* val_vals = (int64_t*)(val + 4);
19840         for (size_t i = 0; i < val_constr.datalen; i++) {
19841                 int64_t val_conv_8 = val_vals[i];
19842                 val_constr.data[i] = val_conv_8;
19843         }
19844         NodeInfo_set_channels(&this_ptr_conv, val_constr);
19845 }
19846
19847 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
19848         LDKNodeInfo this_ptr_conv;
19849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19850         this_ptr_conv.is_owned = false;
19851         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
19852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19854         long ret_ref = (long)ret_var.inner;
19855         if (ret_var.is_owned) {
19856                 ret_ref |= 1;
19857         }
19858         return ret_ref;
19859 }
19860
19861 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
19862         LDKNodeInfo this_ptr_conv;
19863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19864         this_ptr_conv.is_owned = false;
19865         LDKRoutingFees val_conv;
19866         val_conv.inner = (void*)(val & (~1));
19867         val_conv.is_owned = (val & 1) || (val == 0);
19868         val_conv = RoutingFees_clone(&val_conv);
19869         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
19870 }
19871
19872 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
19873         LDKNodeInfo this_ptr_conv;
19874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19875         this_ptr_conv.is_owned = false;
19876         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
19877         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19878         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19879         long ret_ref = (long)ret_var.inner;
19880         if (ret_var.is_owned) {
19881                 ret_ref |= 1;
19882         }
19883         return ret_ref;
19884 }
19885
19886 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
19887         LDKNodeInfo this_ptr_conv;
19888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19889         this_ptr_conv.is_owned = false;
19890         LDKNodeAnnouncementInfo val_conv;
19891         val_conv.inner = (void*)(val & (~1));
19892         val_conv.is_owned = (val & 1) || (val == 0);
19893         val_conv = NodeAnnouncementInfo_clone(&val_conv);
19894         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
19895 }
19896
19897 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
19898         LDKCVec_u64Z channels_arg_constr;
19899         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
19900         if (channels_arg_constr.datalen > 0)
19901                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19902         else
19903                 channels_arg_constr.data = NULL;
19904         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
19905         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
19906                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
19907                 channels_arg_constr.data[i] = channels_arg_conv_8;
19908         }
19909         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
19910         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
19911         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
19912         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
19913         LDKNodeAnnouncementInfo announcement_info_arg_conv;
19914         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
19915         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
19916         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
19917         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
19918         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19919         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19920         long ret_ref = (long)ret_var.inner;
19921         if (ret_var.is_owned) {
19922                 ret_ref |= 1;
19923         }
19924         return ret_ref;
19925 }
19926
19927 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
19928         LDKNodeInfo orig_conv;
19929         orig_conv.inner = (void*)(orig & (~1));
19930         orig_conv.is_owned = false;
19931         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
19932         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19933         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19934         long ret_ref = (long)ret_var.inner;
19935         if (ret_var.is_owned) {
19936                 ret_ref |= 1;
19937         }
19938         return ret_ref;
19939 }
19940
19941 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
19942         LDKNodeInfo obj_conv;
19943         obj_conv.inner = (void*)(obj & (~1));
19944         obj_conv.is_owned = false;
19945         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
19946         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19947         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19948         CVec_u8Z_free(ret_var);
19949         return ret_arr;
19950 }
19951
19952 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
19953         LDKu8slice ser_ref;
19954         ser_ref.datalen = *((uint32_t*)ser);
19955         ser_ref.data = (int8_t*)(ser + 4);
19956         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19957         *ret_conv = NodeInfo_read(ser_ref);
19958         return (long)ret_conv;
19959 }
19960
19961 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
19962         LDKNetworkGraph obj_conv;
19963         obj_conv.inner = (void*)(obj & (~1));
19964         obj_conv.is_owned = false;
19965         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
19966         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19967         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19968         CVec_u8Z_free(ret_var);
19969         return ret_arr;
19970 }
19971
19972 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
19973         LDKu8slice ser_ref;
19974         ser_ref.datalen = *((uint32_t*)ser);
19975         ser_ref.data = (int8_t*)(ser + 4);
19976         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19977         *ret_conv = NetworkGraph_read(ser_ref);
19978         return (long)ret_conv;
19979 }
19980
19981 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
19982         LDKThirtyTwoBytes genesis_hash_ref;
19983         CHECK(*((uint32_t*)genesis_hash) == 32);
19984         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
19985         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
19986         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19987         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19988         long ret_ref = (long)ret_var.inner;
19989         if (ret_var.is_owned) {
19990                 ret_ref |= 1;
19991         }
19992         return ret_ref;
19993 }
19994
19995 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
19996         LDKNetworkGraph this_arg_conv;
19997         this_arg_conv.inner = (void*)(this_arg & (~1));
19998         this_arg_conv.is_owned = false;
19999         LDKNodeAnnouncement msg_conv;
20000         msg_conv.inner = (void*)(msg & (~1));
20001         msg_conv.is_owned = false;
20002         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20003         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
20004         return (long)ret_conv;
20005 }
20006
20007 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
20008         LDKNetworkGraph this_arg_conv;
20009         this_arg_conv.inner = (void*)(this_arg & (~1));
20010         this_arg_conv.is_owned = false;
20011         LDKUnsignedNodeAnnouncement msg_conv;
20012         msg_conv.inner = (void*)(msg & (~1));
20013         msg_conv.is_owned = false;
20014         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20015         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
20016         return (long)ret_conv;
20017 }
20018
20019 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
20020         LDKNetworkGraph this_arg_conv;
20021         this_arg_conv.inner = (void*)(this_arg & (~1));
20022         this_arg_conv.is_owned = false;
20023         LDKChannelAnnouncement msg_conv;
20024         msg_conv.inner = (void*)(msg & (~1));
20025         msg_conv.is_owned = false;
20026         LDKAccess *chain_access_conv_ptr = NULL;
20027         if (chain_access != 0) {
20028                 LDKAccess chain_access_conv;
20029                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20030                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20031                 *chain_access_conv_ptr = chain_access_conv;
20032         }
20033         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20034         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20035         return (long)ret_conv;
20036 }
20037
20038 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
20039         LDKNetworkGraph this_arg_conv;
20040         this_arg_conv.inner = (void*)(this_arg & (~1));
20041         this_arg_conv.is_owned = false;
20042         LDKUnsignedChannelAnnouncement msg_conv;
20043         msg_conv.inner = (void*)(msg & (~1));
20044         msg_conv.is_owned = false;
20045         LDKAccess *chain_access_conv_ptr = NULL;
20046         if (chain_access != 0) {
20047                 LDKAccess chain_access_conv;
20048                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20049                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20050                 *chain_access_conv_ptr = chain_access_conv;
20051         }
20052         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20053         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
20054         return (long)ret_conv;
20055 }
20056
20057 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
20058         LDKNetworkGraph this_arg_conv;
20059         this_arg_conv.inner = (void*)(this_arg & (~1));
20060         this_arg_conv.is_owned = false;
20061         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
20062 }
20063
20064 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
20065         LDKNetworkGraph this_arg_conv;
20066         this_arg_conv.inner = (void*)(this_arg & (~1));
20067         this_arg_conv.is_owned = false;
20068         LDKChannelUpdate msg_conv;
20069         msg_conv.inner = (void*)(msg & (~1));
20070         msg_conv.is_owned = false;
20071         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20072         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
20073         return (long)ret_conv;
20074 }
20075
20076 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
20077         LDKNetworkGraph this_arg_conv;
20078         this_arg_conv.inner = (void*)(this_arg & (~1));
20079         this_arg_conv.is_owned = false;
20080         LDKUnsignedChannelUpdate msg_conv;
20081         msg_conv.inner = (void*)(msg & (~1));
20082         msg_conv.is_owned = false;
20083         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20084         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
20085         return (long)ret_conv;
20086 }
20087
20088 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
20089         LDKFilesystemPersister this_obj_conv;
20090         this_obj_conv.inner = (void*)(this_obj & (~1));
20091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20092         FilesystemPersister_free(this_obj_conv);
20093 }
20094
20095 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(int8_tArray path_to_channel_data) {
20096         LDKCVec_u8Z path_to_channel_data_ref;
20097         path_to_channel_data_ref.datalen = *((uint32_t*)path_to_channel_data);
20098         path_to_channel_data_ref.data = MALLOC(path_to_channel_data_ref.datalen, "LDKCVec_u8Z Bytes");
20099         memcpy(path_to_channel_data_ref.data, (uint8_t*)(path_to_channel_data + 4), path_to_channel_data_ref.datalen);
20100         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_ref);
20101         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20102         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20103         long ret_ref = (long)ret_var.inner;
20104         if (ret_var.is_owned) {
20105                 ret_ref |= 1;
20106         }
20107         return ret_ref;
20108 }
20109
20110 int8_tArray  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
20111         LDKFilesystemPersister this_arg_conv;
20112         this_arg_conv.inner = (void*)(this_arg & (~1));
20113         this_arg_conv.is_owned = false;
20114         LDKCVec_u8Z ret_var = FilesystemPersister_get_data_dir(&this_arg_conv);
20115         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20116         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20117         CVec_u8Z_free(ret_var);
20118         return ret_arr;
20119 }
20120
20121 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(int8_tArray data_dir, uint32_t manager) {
20122         LDKCVec_u8Z data_dir_ref;
20123         data_dir_ref.datalen = *((uint32_t*)data_dir);
20124         data_dir_ref.data = MALLOC(data_dir_ref.datalen, "LDKCVec_u8Z Bytes");
20125         memcpy(data_dir_ref.data, (uint8_t*)(data_dir + 4), data_dir_ref.datalen);
20126         LDKChannelManager manager_conv;
20127         manager_conv.inner = (void*)(manager & (~1));
20128         manager_conv.is_owned = false;
20129         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
20130         *ret_conv = FilesystemPersister_persist_manager(data_dir_ref, &manager_conv);
20131         return (long)ret_conv;
20132 }
20133
20134 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
20135         LDKFilesystemPersister this_arg_conv;
20136         this_arg_conv.inner = (void*)(this_arg & (~1));
20137         this_arg_conv.is_owned = false;
20138         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
20139         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20140         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
20141         return (long)ret_conv;
20142 }
20143
20144 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
20145         LDKFilesystemPersister this_arg_conv;
20146         this_arg_conv.inner = (void*)(this_arg & (~1));
20147         this_arg_conv.is_owned = false;
20148         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
20149         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
20150         return (long)ret;
20151 }
20152