Update auto-generated bindings to LDK v0.0.99
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 void *malloc(size_t size);
16 void free(void *ptr);
17
18 #define MALLOC(a, _) malloc(a)
19 #define FREE(p) if ((long)(p) > 1024) { free(p); }
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
24 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
25 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
27
28 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
29
30 typedef uint32_t int64_tArray;
31 typedef uint32_t int8_tArray;
32 typedef uint32_t uint32_tArray;
33 typedef uint32_t ptrArray;
34 typedef uint32_t jstring;
35
36 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
37         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
38         elems[0] = arr_len;
39         return (uint32_t)elems;
40 }
41
42 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
43         char* err_buf = MALLOC(len + 4, "str conv buf");
44         *((uint32_t*)err_buf) = len;
45         memcpy(err_buf + 4, chars, len);
46         return (uint32_t) err_buf;
47 }
48 static inline LDKStr str_ref_to_owned_c(jstring str) {
49         uint32_t *str_len = (uint32_t*)str;
50         char* newchars = MALLOC(*str_len + 1, "String chars");
51         memcpy(newchars, (const char*)(str + 4), *str_len);
52         newchars[*str_len] = 0;
53         LDKStr res= {
54                 .chars = newchars,
55                 .len = *str_len,
56                 .chars_is_owned = true
57         };
58         return res;
59 }
60
61 typedef bool jboolean;
62
63 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
64         return (uint32_t)MALLOC(size, "JS-Called malloc");
65 }
66 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
67         FREE((void*)ptr);
68 }
69 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
70 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
71         switch (ord) {
72                 case 0: return LDKAccessError_UnknownChain;
73                 case 1: return LDKAccessError_UnknownTx;
74         }
75         abort();
76 }
77 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
78         switch (val) {
79                 case LDKAccessError_UnknownChain: return 0;
80                 case LDKAccessError_UnknownTx: return 1;
81                 default: abort();
82         }
83 }
84 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
85         switch (ord) {
86                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
87                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
88         }
89         abort();
90 }
91 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
92         switch (val) {
93                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
94                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
95                 default: abort();
96         }
97 }
98 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
99         switch (ord) {
100                 case 0: return LDKConfirmationTarget_Background;
101                 case 1: return LDKConfirmationTarget_Normal;
102                 case 2: return LDKConfirmationTarget_HighPriority;
103         }
104         abort();
105 }
106 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
107         switch (val) {
108                 case LDKConfirmationTarget_Background: return 0;
109                 case LDKConfirmationTarget_Normal: return 1;
110                 case LDKConfirmationTarget_HighPriority: return 2;
111                 default: abort();
112         }
113 }
114 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
115         switch (ord) {
116                 case 0: return LDKCreationError_DescriptionTooLong;
117                 case 1: return LDKCreationError_RouteTooLong;
118                 case 2: return LDKCreationError_TimestampOutOfBounds;
119                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
120         }
121         abort();
122 }
123 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
124         switch (val) {
125                 case LDKCreationError_DescriptionTooLong: return 0;
126                 case LDKCreationError_RouteTooLong: return 1;
127                 case LDKCreationError_TimestampOutOfBounds: return 2;
128                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
129                 default: abort();
130         }
131 }
132 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
133         switch (ord) {
134                 case 0: return LDKCurrency_Bitcoin;
135                 case 1: return LDKCurrency_BitcoinTestnet;
136                 case 2: return LDKCurrency_Regtest;
137                 case 3: return LDKCurrency_Simnet;
138                 case 4: return LDKCurrency_Signet;
139         }
140         abort();
141 }
142 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
143         switch (val) {
144                 case LDKCurrency_Bitcoin: return 0;
145                 case LDKCurrency_BitcoinTestnet: return 1;
146                 case LDKCurrency_Regtest: return 2;
147                 case LDKCurrency_Simnet: return 3;
148                 case LDKCurrency_Signet: return 4;
149                 default: abort();
150         }
151 }
152 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
153         switch (ord) {
154                 case 0: return LDKIOError_NotFound;
155                 case 1: return LDKIOError_PermissionDenied;
156                 case 2: return LDKIOError_ConnectionRefused;
157                 case 3: return LDKIOError_ConnectionReset;
158                 case 4: return LDKIOError_ConnectionAborted;
159                 case 5: return LDKIOError_NotConnected;
160                 case 6: return LDKIOError_AddrInUse;
161                 case 7: return LDKIOError_AddrNotAvailable;
162                 case 8: return LDKIOError_BrokenPipe;
163                 case 9: return LDKIOError_AlreadyExists;
164                 case 10: return LDKIOError_WouldBlock;
165                 case 11: return LDKIOError_InvalidInput;
166                 case 12: return LDKIOError_InvalidData;
167                 case 13: return LDKIOError_TimedOut;
168                 case 14: return LDKIOError_WriteZero;
169                 case 15: return LDKIOError_Interrupted;
170                 case 16: return LDKIOError_Other;
171                 case 17: return LDKIOError_UnexpectedEof;
172         }
173         abort();
174 }
175 static inline int32_t LDKIOError_to_js(LDKIOError val) {
176         switch (val) {
177                 case LDKIOError_NotFound: return 0;
178                 case LDKIOError_PermissionDenied: return 1;
179                 case LDKIOError_ConnectionRefused: return 2;
180                 case LDKIOError_ConnectionReset: return 3;
181                 case LDKIOError_ConnectionAborted: return 4;
182                 case LDKIOError_NotConnected: return 5;
183                 case LDKIOError_AddrInUse: return 6;
184                 case LDKIOError_AddrNotAvailable: return 7;
185                 case LDKIOError_BrokenPipe: return 8;
186                 case LDKIOError_AlreadyExists: return 9;
187                 case LDKIOError_WouldBlock: return 10;
188                 case LDKIOError_InvalidInput: return 11;
189                 case LDKIOError_InvalidData: return 12;
190                 case LDKIOError_TimedOut: return 13;
191                 case LDKIOError_WriteZero: return 14;
192                 case LDKIOError_Interrupted: return 15;
193                 case LDKIOError_Other: return 16;
194                 case LDKIOError_UnexpectedEof: return 17;
195                 default: abort();
196         }
197 }
198 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
199         switch (ord) {
200                 case 0: return LDKLevel_Trace;
201                 case 1: return LDKLevel_Debug;
202                 case 2: return LDKLevel_Info;
203                 case 3: return LDKLevel_Warn;
204                 case 4: return LDKLevel_Error;
205         }
206         abort();
207 }
208 static inline int32_t LDKLevel_to_js(LDKLevel val) {
209         switch (val) {
210                 case LDKLevel_Trace: return 0;
211                 case LDKLevel_Debug: return 1;
212                 case LDKLevel_Info: return 2;
213                 case LDKLevel_Warn: return 3;
214                 case LDKLevel_Error: return 4;
215                 default: abort();
216         }
217 }
218 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
219         switch (ord) {
220                 case 0: return LDKNetwork_Bitcoin;
221                 case 1: return LDKNetwork_Testnet;
222                 case 2: return LDKNetwork_Regtest;
223                 case 3: return LDKNetwork_Signet;
224         }
225         abort();
226 }
227 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
228         switch (val) {
229                 case LDKNetwork_Bitcoin: return 0;
230                 case LDKNetwork_Testnet: return 1;
231                 case LDKNetwork_Regtest: return 2;
232                 case LDKNetwork_Signet: return 3;
233                 default: abort();
234         }
235 }
236 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
237         switch (ord) {
238                 case 0: return LDKSecp256k1Error_IncorrectSignature;
239                 case 1: return LDKSecp256k1Error_InvalidMessage;
240                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
241                 case 3: return LDKSecp256k1Error_InvalidSignature;
242                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
243                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
244                 case 6: return LDKSecp256k1Error_InvalidTweak;
245                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
246                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
247         }
248         abort();
249 }
250 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
251         switch (val) {
252                 case LDKSecp256k1Error_IncorrectSignature: return 0;
253                 case LDKSecp256k1Error_InvalidMessage: return 1;
254                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
255                 case LDKSecp256k1Error_InvalidSignature: return 3;
256                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
257                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
258                 case LDKSecp256k1Error_InvalidTweak: return 6;
259                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
260                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
261                 default: abort();
262         }
263 }
264 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
265         switch (ord) {
266                 case 0: return LDKSemanticError_NoPaymentHash;
267                 case 1: return LDKSemanticError_MultiplePaymentHashes;
268                 case 2: return LDKSemanticError_NoDescription;
269                 case 3: return LDKSemanticError_MultipleDescriptions;
270                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
271                 case 5: return LDKSemanticError_InvalidFeatures;
272                 case 6: return LDKSemanticError_InvalidRecoveryId;
273                 case 7: return LDKSemanticError_InvalidSignature;
274         }
275         abort();
276 }
277 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
278         switch (val) {
279                 case LDKSemanticError_NoPaymentHash: return 0;
280                 case LDKSemanticError_MultiplePaymentHashes: return 1;
281                 case LDKSemanticError_NoDescription: return 2;
282                 case LDKSemanticError_MultipleDescriptions: return 3;
283                 case LDKSemanticError_MultiplePaymentSecrets: return 4;
284                 case LDKSemanticError_InvalidFeatures: return 5;
285                 case LDKSemanticError_InvalidRecoveryId: return 6;
286                 case LDKSemanticError_InvalidSignature: return 7;
287                 default: abort();
288         }
289 }
290 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
291         switch (ord) {
292                 case 0: return LDKSiPrefix_Milli;
293                 case 1: return LDKSiPrefix_Micro;
294                 case 2: return LDKSiPrefix_Nano;
295                 case 3: return LDKSiPrefix_Pico;
296         }
297         abort();
298 }
299 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
300         switch (val) {
301                 case LDKSiPrefix_Milli: return 0;
302                 case LDKSiPrefix_Micro: return 1;
303                 case LDKSiPrefix_Nano: return 2;
304                 case LDKSiPrefix_Pico: return 3;
305                 default: abort();
306         }
307 }
308 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
309         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
310         ret->datalen = *((uint32_t*)elems);
311         if (ret->datalen == 0) {
312                 ret->data = NULL;
313         } else {
314                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
315                 int8_t *java_elems = (int8_t*)(elems + 4);
316                 for (size_t i = 0; i < ret->datalen; i++) {
317                         ret->data[i] = java_elems[i];
318                 }
319         }
320         return (uint64_t)ret;
321 }
322 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
323         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
324         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
325         return ret;
326 }
327 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
328         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
329 }
330 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
331         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
332         CHECK(val->result_ok);
333         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
334         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
335         return res_arr;
336 }
337 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
338         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
339         CHECK(!val->result_ok);
340         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
341         return err_conv;
342 }
343 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
344         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
345 }
346 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
347         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
348         CHECK(val->result_ok);
349         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
350         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
351         return res_arr;
352 }
353 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
354         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
355         CHECK(!val->result_ok);
356         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
357         return err_conv;
358 }
359 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
360         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
361 }
362 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
363         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
364         CHECK(val->result_ok);
365         LDKTxCreationKeys res_var = (*val->contents.result);
366         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
367         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
368         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
369         return res_ref;
370 }
371 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
372         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
373         CHECK(!val->result_ok);
374         LDKDecodeError err_var = (*val->contents.err);
375         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
376         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
377         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
378         return err_ref;
379 }
380 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
381         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
382 }
383 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
384         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
385         CHECK(val->result_ok);
386         LDKChannelPublicKeys res_var = (*val->contents.result);
387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
389         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
390         return res_ref;
391 }
392 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
393         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
394         CHECK(!val->result_ok);
395         LDKDecodeError err_var = (*val->contents.err);
396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
398         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
399         return err_ref;
400 }
401 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
402         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
403 }
404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
405         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
406         CHECK(val->result_ok);
407         LDKTxCreationKeys res_var = (*val->contents.result);
408         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
409         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
410         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
411         return res_ref;
412 }
413 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
414         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
415         CHECK(!val->result_ok);
416         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
417         return err_conv;
418 }
419 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
420         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
421         switch(obj->tag) {
422                 case LDKCOption_u32Z_Some: {
423                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
424                 }
425                 case LDKCOption_u32Z_None: {
426                         return 0 /* LDKCOption_u32Z - None */;
427                 }
428                 default: abort();
429         }
430 }
431 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
432         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
433 }
434 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
435         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
436         CHECK(val->result_ok);
437         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
438         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
439         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
440         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
441         return res_ref;
442 }
443 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
444         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
445         CHECK(!val->result_ok);
446         LDKDecodeError err_var = (*val->contents.err);
447         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
448         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
449         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
450         return err_ref;
451 }
452 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
453         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
454 }
455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
456         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
457         CHECK(val->result_ok);
458         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
459         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
460         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
461         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
462         return res_ref;
463 }
464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
465         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
466         CHECK(!val->result_ok);
467         LDKDecodeError err_var = (*val->contents.err);
468         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
469         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
470         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
471         return err_ref;
472 }
473 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
474         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
475 }
476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
477         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
478         CHECK(val->result_ok);
479         LDKChannelTransactionParameters res_var = (*val->contents.result);
480         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
481         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
482         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
483         return res_ref;
484 }
485 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
486         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
487         CHECK(!val->result_ok);
488         LDKDecodeError err_var = (*val->contents.err);
489         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
490         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
491         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
492         return err_ref;
493 }
494 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
495         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
496 }
497 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
498         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
499         CHECK(val->result_ok);
500         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
501         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
504         return res_ref;
505 }
506 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
507         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
508         CHECK(!val->result_ok);
509         LDKDecodeError err_var = (*val->contents.err);
510         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
511         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
512         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
513         return err_ref;
514 }
515 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
516         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
517 }
518 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
519         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
520         CHECK(val->result_ok);
521         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
525         return res_ref;
526 }
527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
528         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
529         CHECK(!val->result_ok);
530         LDKDecodeError err_var = (*val->contents.err);
531         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
532         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
533         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
534         return err_ref;
535 }
536 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
537         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
538 }
539 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
540         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
541         CHECK(val->result_ok);
542         LDKCommitmentTransaction res_var = (*val->contents.result);
543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
545         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
546         return res_ref;
547 }
548 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
549         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
550         CHECK(!val->result_ok);
551         LDKDecodeError err_var = (*val->contents.err);
552         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
553         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
554         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
555         return err_ref;
556 }
557 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
558         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
559 }
560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
561         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
562         CHECK(val->result_ok);
563         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
564         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
565         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
566         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
567         return res_ref;
568 }
569 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
570         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
571         CHECK(!val->result_ok);
572         return *val->contents.err;
573 }
574 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
575         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
576 }
577 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
578         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
579         CHECK(val->result_ok);
580         LDKCVec_SignatureZ res_var = (*val->contents.result);
581         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
582         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
583         for (size_t m = 0; m < res_var.datalen; m++) {
584                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
585                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
586                 res_arr_ptr[m] = res_conv_12_arr;
587         }
588         return res_arr;
589 }
590 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
591         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
592         CHECK(!val->result_ok);
593         return *val->contents.err;
594 }
595 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
596         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
597 }
598 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
599         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
600         CHECK(val->result_ok);
601         return *val->contents.result;
602 }
603 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
604         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
605         CHECK(!val->result_ok);
606         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
607         return err_conv;
608 }
609 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
610         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
611 }
612 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
613         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
614         CHECK(val->result_ok);
615         LDKRouteHop res_var = (*val->contents.result);
616         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
617         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
618         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
619         return res_ref;
620 }
621 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
622         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
623         CHECK(!val->result_ok);
624         LDKDecodeError err_var = (*val->contents.err);
625         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
626         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
627         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
628         return err_ref;
629 }
630 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
631         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
632         ret->datalen = *((uint32_t*)elems);
633         if (ret->datalen == 0) {
634                 ret->data = NULL;
635         } else {
636                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
637                 uint32_t *java_elems = (uint32_t*)(elems + 4);
638                 for (size_t i = 0; i < ret->datalen; i++) {
639                         uint32_t arr_elem = java_elems[i];
640                         LDKRouteHop arr_elem_conv;
641                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
642                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
643                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
644                         ret->data[i] = arr_elem_conv;
645                 }
646         }
647         return (uint64_t)ret;
648 }
649 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
650         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
651         for (size_t i = 0; i < ret.datalen; i++) {
652                 ret.data[i] = RouteHop_clone(&orig->data[i]);
653         }
654         return ret;
655 }
656 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
657         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
658         for (size_t i = 0; i < ret.datalen; i++) {
659                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
660         }
661         return ret;
662 }
663 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
664         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
665 }
666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
667         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
668         CHECK(val->result_ok);
669         LDKRoute res_var = (*val->contents.result);
670         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
671         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
672         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
673         return res_ref;
674 }
675 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
676         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
677         CHECK(!val->result_ok);
678         LDKDecodeError err_var = (*val->contents.err);
679         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
680         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
681         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
682         return err_ref;
683 }
684 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
685         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
686         switch(obj->tag) {
687                 case LDKCOption_u64Z_Some: {
688                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
689                 }
690                 case LDKCOption_u64Z_None: {
691                         return 0 /* LDKCOption_u64Z - None */;
692                 }
693                 default: abort();
694         }
695 }
696 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
697         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
698         ret->datalen = *((uint32_t*)elems);
699         if (ret->datalen == 0) {
700                 ret->data = NULL;
701         } else {
702                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
703                 uint32_t *java_elems = (uint32_t*)(elems + 4);
704                 for (size_t i = 0; i < ret->datalen; i++) {
705                         uint32_t arr_elem = java_elems[i];
706                         LDKChannelDetails arr_elem_conv;
707                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
708                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
709                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
710                         ret->data[i] = arr_elem_conv;
711                 }
712         }
713         return (uint64_t)ret;
714 }
715 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
716         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
717         for (size_t i = 0; i < ret.datalen; i++) {
718                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
719         }
720         return ret;
721 }
722 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
723         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
724         ret->datalen = *((uint32_t*)elems);
725         if (ret->datalen == 0) {
726                 ret->data = NULL;
727         } else {
728                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
729                 uint32_t *java_elems = (uint32_t*)(elems + 4);
730                 for (size_t i = 0; i < ret->datalen; i++) {
731                         uint32_t arr_elem = java_elems[i];
732                         LDKRouteHint arr_elem_conv;
733                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
734                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
735                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
736                         ret->data[i] = arr_elem_conv;
737                 }
738         }
739         return (uint64_t)ret;
740 }
741 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
742         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
743         for (size_t i = 0; i < ret.datalen; i++) {
744                 ret.data[i] = RouteHint_clone(&orig->data[i]);
745         }
746         return ret;
747 }
748 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
749         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
750 }
751 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
752         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
753         CHECK(val->result_ok);
754         LDKRoute res_var = (*val->contents.result);
755         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
756         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
757         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
758         return res_ref;
759 }
760 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
761         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
762         CHECK(!val->result_ok);
763         LDKLightningError err_var = (*val->contents.err);
764         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
765         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
766         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
767         return err_ref;
768 }
769 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
770         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
771 }
772 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
773         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
774         CHECK(val->result_ok);
775         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
776         return (uint64_t)res_ref;
777 }
778 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
779         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
780         CHECK(!val->result_ok);
781         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
782         return err_conv;
783 }
784 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
785         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
786         ret->a = a;
787         LDKTransaction b_ref;
788         b_ref.datalen = *((uint32_t*)b);
789         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
790         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
791         b_ref.data_is_owned = false;
792         ret->b = b_ref;
793         return (uint64_t)ret;
794 }
795 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
796         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
797         return tuple->a;
798 }
799 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
800         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
801         LDKTransaction b_var = tuple->b;
802         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
803         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
804         return b_arr;
805 }
806 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
807         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
808         ret->datalen = *((uint32_t*)elems);
809         if (ret->datalen == 0) {
810                 ret->data = NULL;
811         } else {
812                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
813                 uint32_t *java_elems = (uint32_t*)(elems + 4);
814                 for (size_t i = 0; i < ret->datalen; i++) {
815                         uint32_t arr_elem = java_elems[i];
816                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
817                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
818                         ret->data[i] = arr_elem_conv;
819                 }
820         }
821         return (uint64_t)ret;
822 }
823 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
824         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
825         for (size_t i = 0; i < ret.datalen; i++) {
826                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
827         }
828         return ret;
829 }
830 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
831         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
832         for (size_t i = 0; i < ret.datalen; i++) {
833                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
834         }
835         return ret;
836 }
837 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
838         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
839 }
840 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
841         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
842         CHECK(val->result_ok);
843         return *val->contents.result;
844 }
845 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
846         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
847         CHECK(!val->result_ok);
848         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
849         return err_conv;
850 }
851 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
852         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
853         switch(obj->tag) {
854                 case LDKMonitorEvent_HTLCEvent: {
855                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
856                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
857                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
858                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
859                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
860                 }
861                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
862                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
863                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
864                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
865                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
866                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
867                 }
868                 default: abort();
869         }
870 }
871 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
872         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
873         ret->datalen = *((uint32_t*)elems);
874         if (ret->datalen == 0) {
875                 ret->data = NULL;
876         } else {
877                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
878                 uint32_t *java_elems = (uint32_t*)(elems + 4);
879                 for (size_t i = 0; i < ret->datalen; i++) {
880                         uint32_t arr_elem = java_elems[i];
881                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
882                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
883                         ret->data[i] = arr_elem_conv;
884                 }
885         }
886         return (uint64_t)ret;
887 }
888 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
889         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
890         for (size_t i = 0; i < ret.datalen; i++) {
891                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
892         }
893         return ret;
894 }
895 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
896         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
897         switch(obj->tag) {
898                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
899                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
900                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
901                 }
902                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
903                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
904                 }
905                 default: abort();
906         }
907 }
908 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
909         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
910         switch(obj->tag) {
911                 case LDKSpendableOutputDescriptor_StaticOutput: {
912                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
913                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
914                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
915                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
916                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
917                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
918                 }
919                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
920                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
921                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
922                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
923                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
924                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
925                 }
926                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
927                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
928                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
931                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
932                 }
933                 default: abort();
934         }
935 }
936 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
937         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
938         ret->datalen = *((uint32_t*)elems);
939         if (ret->datalen == 0) {
940                 ret->data = NULL;
941         } else {
942                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
943                 uint32_t *java_elems = (uint32_t*)(elems + 4);
944                 for (size_t i = 0; i < ret->datalen; i++) {
945                         uint32_t arr_elem = java_elems[i];
946                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
947                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
948                         ret->data[i] = arr_elem_conv;
949                 }
950         }
951         return (uint64_t)ret;
952 }
953 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
954         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
955         for (size_t i = 0; i < ret.datalen; i++) {
956                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
957         }
958         return ret;
959 }
960 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
961         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
962         switch(obj->tag) {
963                 case LDKErrorAction_DisconnectPeer: {
964                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
965                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
966                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
967                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
968                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
969                 }
970                 case LDKErrorAction_IgnoreError: {
971                         return 0 /* LDKErrorAction - IgnoreError */;
972                 }
973                 case LDKErrorAction_IgnoreAndLog: {
974                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
975                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
976                 }
977                 case LDKErrorAction_SendErrorMessage: {
978                         LDKErrorMessage msg_var = obj->send_error_message.msg;
979                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
980                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
981                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
982                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
983                 }
984                 default: abort();
985         }
986 }
987 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
988         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
989         switch(obj->tag) {
990                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
991                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
992                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
993                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
994                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
995                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
996                 }
997                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
998                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
999                 }
1000                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1001                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1002                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1003                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1004                 }
1005                 default: abort();
1006         }
1007 }
1008 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1009         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1010         switch(obj->tag) {
1011                 case LDKMessageSendEvent_SendAcceptChannel: {
1012                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1013                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1014                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1015                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1018                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1019                 }
1020                 case LDKMessageSendEvent_SendOpenChannel: {
1021                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1022                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1023                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1024                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1025                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1026                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1027                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1028                 }
1029                 case LDKMessageSendEvent_SendFundingCreated: {
1030                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1031                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1032                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1033                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1034                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1035                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1036                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1037                 }
1038                 case LDKMessageSendEvent_SendFundingSigned: {
1039                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1040                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1041                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1042                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1043                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1044                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1045                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1046                 }
1047                 case LDKMessageSendEvent_SendFundingLocked: {
1048                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1049                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1050                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1051                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1054                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1055                 }
1056                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1057                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1058                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1059                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1060                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1061                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1062                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1063                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1064                 }
1065                 case LDKMessageSendEvent_UpdateHTLCs: {
1066                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1067                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1068                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1069                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1070                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1071                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1072                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1073                 }
1074                 case LDKMessageSendEvent_SendRevokeAndACK: {
1075                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1076                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1077                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1078                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1081                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1082                 }
1083                 case LDKMessageSendEvent_SendClosingSigned: {
1084                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1085                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1086                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1087                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1088                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1089                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1090                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1091                 }
1092                 case LDKMessageSendEvent_SendShutdown: {
1093                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1094                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1095                         LDKShutdown msg_var = obj->send_shutdown.msg;
1096                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1099                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1100                 }
1101                 case LDKMessageSendEvent_SendChannelReestablish: {
1102                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1103                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1104                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1105                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1106                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1107                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1108                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1109                 }
1110                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1111                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1112                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1113                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1114                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1115                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1116                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1117                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1118                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1119                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1120                 }
1121                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1122                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1123                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1124                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1125                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1126                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1127                 }
1128                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1129                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1130                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1131                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1132                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1133                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1134                 }
1135                 case LDKMessageSendEvent_SendChannelUpdate: {
1136                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1137                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1138                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1139                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1140                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1141                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1142                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1143                 }
1144                 case LDKMessageSendEvent_HandleError: {
1145                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1146                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1147                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1148                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1149                 }
1150                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1151                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1152                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1153                 }
1154                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1155                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1156                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1157                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1158                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1159                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1160                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1161                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1162                 }
1163                 case LDKMessageSendEvent_SendShortIdsQuery: {
1164                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1165                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1166                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1167                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1168                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1169                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1170                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1171                 }
1172                 case LDKMessageSendEvent_SendReplyChannelRange: {
1173                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1174                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1175                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1176                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1177                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1178                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1179                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1180                 }
1181                 default: abort();
1182         }
1183 }
1184 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1185         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1186         ret->datalen = *((uint32_t*)elems);
1187         if (ret->datalen == 0) {
1188                 ret->data = NULL;
1189         } else {
1190                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1191                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1192                 for (size_t i = 0; i < ret->datalen; i++) {
1193                         uint32_t arr_elem = java_elems[i];
1194                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1195                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1196                         ret->data[i] = arr_elem_conv;
1197                 }
1198         }
1199         return (uint64_t)ret;
1200 }
1201 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1202         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1203         for (size_t i = 0; i < ret.datalen; i++) {
1204                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1205         }
1206         return ret;
1207 }
1208 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1209         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1210 }
1211 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1212         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1213         CHECK(val->result_ok);
1214         LDKInitFeatures res_var = (*val->contents.result);
1215         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1216         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1217         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1218         return res_ref;
1219 }
1220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1221         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1222         CHECK(!val->result_ok);
1223         LDKDecodeError err_var = (*val->contents.err);
1224         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1225         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1226         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1227         return err_ref;
1228 }
1229 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1230         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1231 }
1232 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1233         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1234         CHECK(val->result_ok);
1235         LDKNodeFeatures res_var = (*val->contents.result);
1236         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1239         return res_ref;
1240 }
1241 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1242         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1243         CHECK(!val->result_ok);
1244         LDKDecodeError err_var = (*val->contents.err);
1245         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1248         return err_ref;
1249 }
1250 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1251         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1252 }
1253 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1254         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1255         CHECK(val->result_ok);
1256         LDKChannelFeatures res_var = (*val->contents.result);
1257         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1260         return res_ref;
1261 }
1262 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1263         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1264         CHECK(!val->result_ok);
1265         LDKDecodeError err_var = (*val->contents.err);
1266         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1267         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1268         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1269         return err_ref;
1270 }
1271 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1272         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1273 }
1274 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1275         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1276         CHECK(val->result_ok);
1277         LDKInvoiceFeatures res_var = (*val->contents.result);
1278         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1281         return res_ref;
1282 }
1283 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1284         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1285         CHECK(!val->result_ok);
1286         LDKDecodeError err_var = (*val->contents.err);
1287         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1288         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1289         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1290         return err_ref;
1291 }
1292 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1293         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1294 }
1295 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1296         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1297         CHECK(val->result_ok);
1298         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1299         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1302         return res_ref;
1303 }
1304 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1305         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1306         CHECK(!val->result_ok);
1307         LDKDecodeError err_var = (*val->contents.err);
1308         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1309         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1310         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1311         return err_ref;
1312 }
1313 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1314         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1315 }
1316 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1317         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1318         CHECK(val->result_ok);
1319         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1320         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1321         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1322         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1323         return res_ref;
1324 }
1325 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1326         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1327         CHECK(!val->result_ok);
1328         LDKDecodeError err_var = (*val->contents.err);
1329         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1332         return err_ref;
1333 }
1334 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1335         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1336 }
1337 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1338         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1339         CHECK(val->result_ok);
1340         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1341         return res_ref;
1342 }
1343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1344         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1345         CHECK(!val->result_ok);
1346         LDKDecodeError err_var = (*val->contents.err);
1347         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1350         return err_ref;
1351 }
1352 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1353         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1354         LDKSignature a_ref;
1355         CHECK(*((uint32_t*)a) == 64);
1356         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1357         ret->a = a_ref;
1358         LDKCVec_SignatureZ b_constr;
1359         b_constr.datalen = *((uint32_t*)b);
1360         if (b_constr.datalen > 0)
1361                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1362         else
1363                 b_constr.data = NULL;
1364         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1365         for (size_t m = 0; m < b_constr.datalen; m++) {
1366                 int8_tArray b_conv_12 = b_vals[m];
1367                 LDKSignature b_conv_12_ref;
1368                 CHECK(*((uint32_t*)b_conv_12) == 64);
1369                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1370                 b_constr.data[m] = b_conv_12_ref;
1371         }
1372         ret->b = b_constr;
1373         return (uint64_t)ret;
1374 }
1375 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1376         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1377         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1378         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1379         return a_arr;
1380 }
1381 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1382         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1383         LDKCVec_SignatureZ b_var = tuple->b;
1384         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1385         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1386         for (size_t m = 0; m < b_var.datalen; m++) {
1387                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1388                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1389                 b_arr_ptr[m] = b_conv_12_arr;
1390         }
1391         return b_arr;
1392 }
1393 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1394         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1395 }
1396 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1397         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1398         CHECK(val->result_ok);
1399         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1400         return res_ref;
1401 }
1402 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1403         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1404         CHECK(!val->result_ok);
1405         return *val->contents.err;
1406 }
1407 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1408         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1409 }
1410 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1411         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1412         CHECK(val->result_ok);
1413         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1414         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1415         return res_arr;
1416 }
1417 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1418         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1419         CHECK(!val->result_ok);
1420         return *val->contents.err;
1421 }
1422 typedef struct LDKBaseSign_JCalls {
1423         atomic_size_t refcnt;
1424         uint32_t get_per_commitment_point_meth;
1425         uint32_t release_commitment_secret_meth;
1426         uint32_t channel_keys_id_meth;
1427         uint32_t sign_counterparty_commitment_meth;
1428         uint32_t sign_holder_commitment_and_htlcs_meth;
1429         uint32_t sign_justice_revoked_output_meth;
1430         uint32_t sign_justice_revoked_htlc_meth;
1431         uint32_t sign_counterparty_htlc_transaction_meth;
1432         uint32_t sign_closing_transaction_meth;
1433         uint32_t sign_channel_announcement_meth;
1434         uint32_t ready_channel_meth;
1435 } LDKBaseSign_JCalls;
1436 static void LDKBaseSign_JCalls_free(void* this_arg) {
1437         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1438         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1439                 js_free(j_calls->get_per_commitment_point_meth);
1440                 js_free(j_calls->release_commitment_secret_meth);
1441                 js_free(j_calls->channel_keys_id_meth);
1442                 js_free(j_calls->sign_counterparty_commitment_meth);
1443                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1444                 js_free(j_calls->sign_justice_revoked_output_meth);
1445                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1446                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1447                 js_free(j_calls->sign_closing_transaction_meth);
1448                 js_free(j_calls->sign_channel_announcement_meth);
1449                 js_free(j_calls->ready_channel_meth);
1450                 FREE(j_calls);
1451         }
1452 }
1453 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1454         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1455         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1456         LDKPublicKey ret_ref;
1457         CHECK(*((uint32_t*)ret) == 33);
1458         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1459         return ret_ref;
1460 }
1461 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1462         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1463         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1464         LDKThirtyTwoBytes ret_ref;
1465         CHECK(*((uint32_t*)ret) == 32);
1466         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1467         return ret_ref;
1468 }
1469 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1470         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1471         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1472         LDKThirtyTwoBytes ret_ref;
1473         CHECK(*((uint32_t*)ret) == 32);
1474         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1475         return ret_ref;
1476 }
1477 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1478         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1479         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1480         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1481         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1482         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1483         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1484         if (commitment_tx_var.is_owned) {
1485                 commitment_tx_ref |= 1;
1486         }
1487         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1488         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1489         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1490         return ret_conv;
1491 }
1492 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1493         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1494         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1495         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1496         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1497         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1498         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1499         if (commitment_tx_var.is_owned) {
1500                 commitment_tx_ref |= 1;
1501         }
1502         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1503         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1504         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1505         return ret_conv;
1506 }
1507 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
1508         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1509         LDKTransaction justice_tx_var = justice_tx;
1510         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1511         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1512         Transaction_free(justice_tx_var);
1513         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1514         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1515         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1516         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1517         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1518         return ret_conv;
1519 }
1520 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_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) {
1521         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1522         LDKTransaction justice_tx_var = justice_tx;
1523         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1524         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1525         Transaction_free(justice_tx_var);
1526         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1527         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1528         LDKHTLCOutputInCommitment htlc_var = *htlc;
1529         htlc_var = HTLCOutputInCommitment_clone(htlc);
1530         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1531         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1532         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1533         if (htlc_var.is_owned) {
1534                 htlc_ref |= 1;
1535         }
1536         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1537         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1538         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1539         return ret_conv;
1540 }
1541 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) {
1542         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1543         LDKTransaction htlc_tx_var = htlc_tx;
1544         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1545         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1546         Transaction_free(htlc_tx_var);
1547         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1548         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1549         LDKHTLCOutputInCommitment htlc_var = *htlc;
1550         htlc_var = HTLCOutputInCommitment_clone(htlc);
1551         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1552         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1553         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1554         if (htlc_var.is_owned) {
1555                 htlc_ref |= 1;
1556         }
1557         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);
1558         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1559         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1560         return ret_conv;
1561 }
1562 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1563         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1564         LDKTransaction closing_tx_var = closing_tx;
1565         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1566         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1567         Transaction_free(closing_tx_var);
1568         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1569         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1570         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1571         return ret_conv;
1572 }
1573 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1574         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1575         LDKUnsignedChannelAnnouncement msg_var = *msg;
1576         msg_var = UnsignedChannelAnnouncement_clone(msg);
1577         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1578         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1579         uint64_t msg_ref = (uint64_t)msg_var.inner;
1580         if (msg_var.is_owned) {
1581                 msg_ref |= 1;
1582         }
1583         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1584         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1585         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1586         return ret_conv;
1587 }
1588 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1589         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1590         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1591         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1592         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1593         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1594         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1595         if (channel_parameters_var.is_owned) {
1596                 channel_parameters_ref |= 1;
1597         }
1598         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1599 }
1600 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1601         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1602         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1603         return (void*) this_arg;
1604 }
1605 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1606         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1607         atomic_init(&calls->refcnt, 1);
1608         //TODO: Assign calls->o from o
1609
1610         LDKChannelPublicKeys pubkeys_conv;
1611         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1612         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1613         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1614
1615         LDKBaseSign ret = {
1616                 .this_arg = (void*) calls,
1617                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1618                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1619                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1620                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1621                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1622                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1623                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1624                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1625                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1626                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1627                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1628                 .free = LDKBaseSign_JCalls_free,
1629                 .pubkeys = pubkeys_conv,
1630                 .set_pubkeys = NULL,
1631         };
1632         return ret;
1633 }
1634 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1635         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1636         *res_ptr = LDKBaseSign_init(o, pubkeys);
1637         return (long)res_ptr;
1638 }
1639 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1640         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1641         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1642         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1643         return ret_arr;
1644 }
1645
1646 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1647         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1648         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1649         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1650         return ret_arr;
1651 }
1652
1653 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1654         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1655         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1656         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1657         return ret_arr;
1658 }
1659
1660 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1661         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1662         LDKCommitmentTransaction commitment_tx_conv;
1663         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1664         commitment_tx_conv.is_owned = false;
1665         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1666         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1667         return (uint64_t)ret_conv;
1668 }
1669
1670 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1671         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1672         LDKHolderCommitmentTransaction commitment_tx_conv;
1673         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1674         commitment_tx_conv.is_owned = false;
1675         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1676         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1677         return (uint64_t)ret_conv;
1678 }
1679
1680 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
1681         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1682         LDKTransaction justice_tx_ref;
1683         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1684         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1685         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1686         justice_tx_ref.data_is_owned = true;
1687         unsigned char per_commitment_key_arr[32];
1688         CHECK(*((uint32_t*)per_commitment_key) == 32);
1689         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1690         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1691         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1692         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1693         return (uint64_t)ret_conv;
1694 }
1695
1696 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1697         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1698         LDKTransaction justice_tx_ref;
1699         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1700         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1701         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1702         justice_tx_ref.data_is_owned = true;
1703         unsigned char per_commitment_key_arr[32];
1704         CHECK(*((uint32_t*)per_commitment_key) == 32);
1705         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1706         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1707         LDKHTLCOutputInCommitment htlc_conv;
1708         htlc_conv.inner = (void*)(htlc & (~1));
1709         htlc_conv.is_owned = false;
1710         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1711         *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1712         return (uint64_t)ret_conv;
1713 }
1714
1715 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) {
1716         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1717         LDKTransaction htlc_tx_ref;
1718         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1719         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1720         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1721         htlc_tx_ref.data_is_owned = true;
1722         LDKPublicKey per_commitment_point_ref;
1723         CHECK(*((uint32_t*)per_commitment_point) == 33);
1724         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1725         LDKHTLCOutputInCommitment htlc_conv;
1726         htlc_conv.inner = (void*)(htlc & (~1));
1727         htlc_conv.is_owned = false;
1728         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1729         *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);
1730         return (uint64_t)ret_conv;
1731 }
1732
1733 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1734         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1735         LDKTransaction closing_tx_ref;
1736         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1737         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1738         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1739         closing_tx_ref.data_is_owned = true;
1740         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1741         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1742         return (uint64_t)ret_conv;
1743 }
1744
1745 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1746         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1747         LDKUnsignedChannelAnnouncement msg_conv;
1748         msg_conv.inner = (void*)(msg & (~1));
1749         msg_conv.is_owned = false;
1750         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1751         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1752         return (uint64_t)ret_conv;
1753 }
1754
1755 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1756         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1757         LDKChannelTransactionParameters channel_parameters_conv;
1758         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1759         channel_parameters_conv.is_owned = false;
1760         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1761 }
1762
1763 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1764         if (this_arg->set_pubkeys != NULL)
1765                 this_arg->set_pubkeys(this_arg);
1766         return this_arg->pubkeys;
1767 }
1768 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1769         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1770         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1771         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1772         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1773         uint64_t ret_ref = (uint64_t)ret_var.inner;
1774         if (ret_var.is_owned) {
1775                 ret_ref |= 1;
1776         }
1777         return ret_ref;
1778 }
1779
1780 typedef struct LDKSign_JCalls {
1781         atomic_size_t refcnt;
1782         LDKBaseSign_JCalls* BaseSign;
1783         uint32_t write_meth;
1784 } LDKSign_JCalls;
1785 static void LDKSign_JCalls_free(void* this_arg) {
1786         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1787         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1788                 js_free(j_calls->write_meth);
1789                 FREE(j_calls);
1790         }
1791 }
1792 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1793         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1794         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1795         LDKCVec_u8Z ret_ref;
1796         ret_ref.datalen = *((uint32_t*)ret);
1797         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1798         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1799         return ret_ref;
1800 }
1801 static void* LDKSign_JCalls_clone(const void* this_arg) {
1802         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1804         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1805         return (void*) this_arg;
1806 }
1807 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1808         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1809         atomic_init(&calls->refcnt, 1);
1810         //TODO: Assign calls->o from o
1811
1812         LDKChannelPublicKeys pubkeys_conv;
1813         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1814         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1815         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1816
1817         LDKSign ret = {
1818                 .this_arg = (void*) calls,
1819                 .write = write_LDKSign_jcall,
1820                 .clone = LDKSign_JCalls_clone,
1821                 .free = LDKSign_JCalls_free,
1822                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1823         };
1824         calls->BaseSign = ret.BaseSign.this_arg;
1825         return ret;
1826 }
1827 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1828         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1829         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1830         return (long)res_ptr;
1831 }
1832 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1833         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1834         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1835         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1836         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1837         CVec_u8Z_free(ret_var);
1838         return ret_arr;
1839 }
1840
1841 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1842         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1843 }
1844 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1845         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1846         CHECK(val->result_ok);
1847         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
1848         *ret = Sign_clone(&(*val->contents.result));
1849         return (uint64_t)ret;
1850 }
1851 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
1852         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1853         CHECK(!val->result_ok);
1854         LDKDecodeError err_var = (*val->contents.err);
1855         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1856         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1857         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1858         return err_ref;
1859 }
1860 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
1861         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
1862 }
1863 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
1864         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1865         CHECK(val->result_ok);
1866         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
1867         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
1868         return es_arr;
1869 }
1870 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
1871         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1872         CHECK(!val->result_ok);
1873         return *val->contents.err;
1874 }
1875 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
1876         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
1877         for (size_t i = 0; i < ret.datalen; i++) {
1878                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
1879         }
1880         return ret;
1881 }
1882 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
1883         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
1884 }
1885 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
1886         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1887         CHECK(val->result_ok);
1888         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
1889         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1890         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1891         for (size_t m = 0; m < res_var.datalen; m++) {
1892                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
1893                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1894                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
1895                 res_arr_ptr[m] = res_conv_12_arr;
1896         }
1897         return res_arr;
1898 }
1899 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
1900         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1901         CHECK(!val->result_ok);
1902         return *val->contents.err;
1903 }
1904 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
1905         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
1906 }
1907 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
1908         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1909         CHECK(val->result_ok);
1910         LDKInMemorySigner res_var = (*val->contents.result);
1911         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1912         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1913         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1914         return res_ref;
1915 }
1916 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
1917         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1918         CHECK(!val->result_ok);
1919         LDKDecodeError err_var = (*val->contents.err);
1920         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1921         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1922         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1923         return err_ref;
1924 }
1925 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
1926         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
1927         ret->datalen = *((uint32_t*)elems);
1928         if (ret->datalen == 0) {
1929                 ret->data = NULL;
1930         } else {
1931                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
1932                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1933                 for (size_t i = 0; i < ret->datalen; i++) {
1934                         uint32_t arr_elem = java_elems[i];
1935                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
1936                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
1937                         ret->data[i] = arr_elem_conv;
1938                 }
1939         }
1940         return (uint64_t)ret;
1941 }
1942 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1943         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1944         for (size_t i = 0; i < ret.datalen; i++) {
1945                 ret.data[i] = TxOut_clone(&orig->data[i]);
1946         }
1947         return ret;
1948 }
1949 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
1950         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
1951 }
1952 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
1953         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1954         CHECK(val->result_ok);
1955         LDKTransaction res_var = (*val->contents.result);
1956         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1957         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
1958         return res_arr;
1959 }
1960 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
1961         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1962         CHECK(!val->result_ok);
1963         return *val->contents.err;
1964 }
1965 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1966         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1967         LDKThirtyTwoBytes a_ref;
1968         CHECK(*((uint32_t*)a) == 32);
1969         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1970         ret->a = a_ref;
1971         LDKChannelMonitor b_conv;
1972         b_conv.inner = (void*)(b & (~1));
1973         b_conv.is_owned = (b & 1) || (b == 0);
1974         b_conv = ChannelMonitor_clone(&b_conv);
1975         ret->b = b_conv;
1976         return (uint64_t)ret;
1977 }
1978 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1979         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1980         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1981         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1982         return a_arr;
1983 }
1984 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1985         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1986         LDKChannelMonitor b_var = tuple->b;
1987         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1988         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1989         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
1990         return b_ref;
1991 }
1992 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
1993         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
1994         ret->datalen = *((uint32_t*)elems);
1995         if (ret->datalen == 0) {
1996                 ret->data = NULL;
1997         } else {
1998                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
1999                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2000                 for (size_t i = 0; i < ret->datalen; i++) {
2001                         uint32_t arr_elem = java_elems[i];
2002                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2003                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2004                         ret->data[i] = arr_elem_conv;
2005                 }
2006         }
2007         return (uint64_t)ret;
2008 }
2009 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2010         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2011 }
2012 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2013         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2014         CHECK(val->result_ok);
2015         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2016         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2017         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2018         for (size_t m = 0; m < res_var.datalen; m++) {
2019                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2020                 res_arr_ptr[m] = res_conv_38_ref;
2021         }
2022         return res_arr;
2023 }
2024 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2025         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2026         CHECK(!val->result_ok);
2027         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2028         return err_conv;
2029 }
2030 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2031         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2032         switch(obj->tag) {
2033                 case LDKCOption_u16Z_Some: {
2034                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2035                 }
2036                 case LDKCOption_u16Z_None: {
2037                         return 0 /* LDKCOption_u16Z - None */;
2038                 }
2039                 default: abort();
2040         }
2041 }
2042 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2043         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2044         switch(obj->tag) {
2045                 case LDKAPIError_APIMisuseError: {
2046                         LDKStr err_str = obj->api_misuse_error.err;
2047                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2048                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2049                 }
2050                 case LDKAPIError_FeeRateTooHigh: {
2051                         LDKStr err_str = obj->fee_rate_too_high.err;
2052                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2053                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2054                 }
2055                 case LDKAPIError_RouteError: {
2056                         LDKStr err_str = obj->route_error.err;
2057                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2058                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2059                 }
2060                 case LDKAPIError_ChannelUnavailable: {
2061                         LDKStr err_str = obj->channel_unavailable.err;
2062                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2063                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2064                 }
2065                 case LDKAPIError_MonitorUpdateFailed: {
2066                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2067                 }
2068                 default: abort();
2069         }
2070 }
2071 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2072         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2073 }
2074 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2075         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2076         CHECK(val->result_ok);
2077         return *val->contents.result;
2078 }
2079 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2080         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2081         CHECK(!val->result_ok);
2082         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2083         return err_ref;
2084 }
2085 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2086         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2087         ret->datalen = *((uint32_t*)elems);
2088         if (ret->datalen == 0) {
2089                 ret->data = NULL;
2090         } else {
2091                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2092                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2093                 for (size_t i = 0; i < ret->datalen; i++) {
2094                         uint32_t arr_elem = java_elems[i];
2095                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2096                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2097                         ret->data[i] = arr_elem_conv;
2098                 }
2099         }
2100         return (uint64_t)ret;
2101 }
2102 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2103         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2104         for (size_t i = 0; i < ret.datalen; i++) {
2105                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2106         }
2107         return ret;
2108 }
2109 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2110         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2111         ret->datalen = *((uint32_t*)elems);
2112         if (ret->datalen == 0) {
2113                 ret->data = NULL;
2114         } else {
2115                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2116                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2117                 for (size_t i = 0; i < ret->datalen; i++) {
2118                         uint32_t arr_elem = java_elems[i];
2119                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2120                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2121                         ret->data[i] = arr_elem_conv;
2122                 }
2123         }
2124         return (uint64_t)ret;
2125 }
2126 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2127         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2128         for (size_t i = 0; i < ret.datalen; i++) {
2129                 ret.data[i] = APIError_clone(&orig->data[i]);
2130         }
2131         return ret;
2132 }
2133 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2134         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2135         switch(obj->tag) {
2136                 case LDKPaymentSendFailure_ParameterError: {
2137                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2138                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2139                 }
2140                 case LDKPaymentSendFailure_PathParameterError: {
2141                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2142                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2143                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2144                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2145                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2146                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2147                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2148                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2149                         }
2150                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2151                 }
2152                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2153                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2154                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2155                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2156                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2157                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2158                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2159                         }
2160                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2161                 }
2162                 case LDKPaymentSendFailure_PartialFailure: {
2163                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2164                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2165                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2166                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2167                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2168                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2169                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2170                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2171                         }
2172                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2173                 }
2174                 default: abort();
2175         }
2176 }
2177 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2178         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2179 }
2180 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2181         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2182         CHECK(val->result_ok);
2183         return *val->contents.result;
2184 }
2185 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2186         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2187         CHECK(!val->result_ok);
2188         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2189         return err_ref;
2190 }
2191 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2192         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2193         switch(obj->tag) {
2194                 case LDKNetAddress_IPv4: {
2195                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2196                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2197                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2198                 }
2199                 case LDKNetAddress_IPv6: {
2200                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2201                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2202                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2203                 }
2204                 case LDKNetAddress_OnionV2: {
2205                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2206                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2207                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2208                 }
2209                 case LDKNetAddress_OnionV3: {
2210                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2211                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2212                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2213                 }
2214                 default: abort();
2215         }
2216 }
2217 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2218         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2219         ret->datalen = *((uint32_t*)elems);
2220         if (ret->datalen == 0) {
2221                 ret->data = NULL;
2222         } else {
2223                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2224                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2225                 for (size_t i = 0; i < ret->datalen; i++) {
2226                         uint32_t arr_elem = java_elems[i];
2227                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2228                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2229                         ret->data[i] = arr_elem_conv;
2230                 }
2231         }
2232         return (uint64_t)ret;
2233 }
2234 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2235         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2236         for (size_t i = 0; i < ret.datalen; i++) {
2237                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2238         }
2239         return ret;
2240 }
2241 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2242         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2243         LDKThirtyTwoBytes a_ref;
2244         CHECK(*((uint32_t*)a) == 32);
2245         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2246         ret->a = a_ref;
2247         LDKThirtyTwoBytes b_ref;
2248         CHECK(*((uint32_t*)b) == 32);
2249         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2250         ret->b = b_ref;
2251         return (uint64_t)ret;
2252 }
2253 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2254         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2255         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2256         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2257         return a_arr;
2258 }
2259 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2260         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2261         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2262         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2263         return b_arr;
2264 }
2265 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2266         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2267 }
2268 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2269         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2270         CHECK(val->result_ok);
2271         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2272         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2273         return res_arr;
2274 }
2275 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2276         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2277         CHECK(!val->result_ok);
2278         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2279         return err_ref;
2280 }
2281 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2282         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2283         ret->datalen = *((uint32_t*)elems);
2284         if (ret->datalen == 0) {
2285                 ret->data = NULL;
2286         } else {
2287                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2288                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2289                 for (size_t i = 0; i < ret->datalen; i++) {
2290                         uint32_t arr_elem = java_elems[i];
2291                         LDKChannelMonitor arr_elem_conv;
2292                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2293                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2294                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2295                         ret->data[i] = arr_elem_conv;
2296                 }
2297         }
2298         return (uint64_t)ret;
2299 }
2300 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2301         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2302         for (size_t i = 0; i < ret.datalen; i++) {
2303                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2304         }
2305         return ret;
2306 }
2307 typedef struct LDKWatch_JCalls {
2308         atomic_size_t refcnt;
2309         uint32_t watch_channel_meth;
2310         uint32_t update_channel_meth;
2311         uint32_t release_pending_monitor_events_meth;
2312 } LDKWatch_JCalls;
2313 static void LDKWatch_JCalls_free(void* this_arg) {
2314         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2315         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2316                 js_free(j_calls->watch_channel_meth);
2317                 js_free(j_calls->update_channel_meth);
2318                 js_free(j_calls->release_pending_monitor_events_meth);
2319                 FREE(j_calls);
2320         }
2321 }
2322 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2323         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2324         LDKOutPoint funding_txo_var = funding_txo;
2325         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2326         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2327         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2328         if (funding_txo_var.is_owned) {
2329                 funding_txo_ref |= 1;
2330         }
2331         LDKChannelMonitor monitor_var = monitor;
2332         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2333         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2334         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2335         if (monitor_var.is_owned) {
2336                 monitor_ref |= 1;
2337         }
2338         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2339         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2340         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2341         return ret_conv;
2342 }
2343 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2344         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2345         LDKOutPoint funding_txo_var = funding_txo;
2346         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2347         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2348         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2349         if (funding_txo_var.is_owned) {
2350                 funding_txo_ref |= 1;
2351         }
2352         LDKChannelMonitorUpdate update_var = update;
2353         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2354         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2355         uint64_t update_ref = (uint64_t)update_var.inner;
2356         if (update_var.is_owned) {
2357                 update_ref |= 1;
2358         }
2359         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2360         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2361         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2362         return ret_conv;
2363 }
2364 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2365         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2366         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2367         LDKCVec_MonitorEventZ ret_constr;
2368         ret_constr.datalen = *((uint32_t*)ret);
2369         if (ret_constr.datalen > 0)
2370                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2371         else
2372                 ret_constr.data = NULL;
2373         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2374         for (size_t o = 0; o < ret_constr.datalen; o++) {
2375                 uint32_t ret_conv_14 = ret_vals[o];
2376                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2377                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2378                 ret_constr.data[o] = ret_conv_14_conv;
2379         }
2380         return ret_constr;
2381 }
2382 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2383         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2384         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2385         return (void*) this_arg;
2386 }
2387 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2388         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2389         atomic_init(&calls->refcnt, 1);
2390         //TODO: Assign calls->o from o
2391
2392         LDKWatch ret = {
2393                 .this_arg = (void*) calls,
2394                 .watch_channel = watch_channel_LDKWatch_jcall,
2395                 .update_channel = update_channel_LDKWatch_jcall,
2396                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2397                 .free = LDKWatch_JCalls_free,
2398         };
2399         return ret;
2400 }
2401 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2402         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2403         *res_ptr = LDKWatch_init(o);
2404         return (long)res_ptr;
2405 }
2406 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2407         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2408         LDKOutPoint funding_txo_conv;
2409         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2410         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2411         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2412         LDKChannelMonitor monitor_conv;
2413         monitor_conv.inner = (void*)(monitor & (~1));
2414         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2415         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2416         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2417         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2418         return (uint64_t)ret_conv;
2419 }
2420
2421 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2422         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2423         LDKOutPoint funding_txo_conv;
2424         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2425         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2426         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2427         LDKChannelMonitorUpdate update_conv;
2428         update_conv.inner = (void*)(update & (~1));
2429         update_conv.is_owned = (update & 1) || (update == 0);
2430         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2431         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2432         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2433         return (uint64_t)ret_conv;
2434 }
2435
2436 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2437         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2438         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2439         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2440         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2441         for (size_t o = 0; o < ret_var.datalen; o++) {
2442                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2443                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2444                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2445                 ret_arr_ptr[o] = ret_conv_14_ref;
2446         }
2447         FREE(ret_var.data);
2448         return ret_arr;
2449 }
2450
2451 typedef struct LDKBroadcasterInterface_JCalls {
2452         atomic_size_t refcnt;
2453         uint32_t broadcast_transaction_meth;
2454 } LDKBroadcasterInterface_JCalls;
2455 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2456         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2457         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2458                 js_free(j_calls->broadcast_transaction_meth);
2459                 FREE(j_calls);
2460         }
2461 }
2462 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2463         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2464         LDKTransaction tx_var = tx;
2465         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2466         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2467         Transaction_free(tx_var);
2468         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2469 }
2470 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2471         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2472         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2473         return (void*) this_arg;
2474 }
2475 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2476         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2477         atomic_init(&calls->refcnt, 1);
2478         //TODO: Assign calls->o from o
2479
2480         LDKBroadcasterInterface ret = {
2481                 .this_arg = (void*) calls,
2482                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2483                 .free = LDKBroadcasterInterface_JCalls_free,
2484         };
2485         return ret;
2486 }
2487 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2488         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2489         *res_ptr = LDKBroadcasterInterface_init(o);
2490         return (long)res_ptr;
2491 }
2492 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2493         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2494         LDKTransaction tx_ref;
2495         tx_ref.datalen = *((uint32_t*)tx);
2496         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2497         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2498         tx_ref.data_is_owned = true;
2499         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2500 }
2501
2502 typedef struct LDKKeysInterface_JCalls {
2503         atomic_size_t refcnt;
2504         uint32_t get_node_secret_meth;
2505         uint32_t get_destination_script_meth;
2506         uint32_t get_shutdown_pubkey_meth;
2507         uint32_t get_channel_signer_meth;
2508         uint32_t get_secure_random_bytes_meth;
2509         uint32_t read_chan_signer_meth;
2510         uint32_t sign_invoice_meth;
2511 } LDKKeysInterface_JCalls;
2512 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2513         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2514         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2515                 js_free(j_calls->get_node_secret_meth);
2516                 js_free(j_calls->get_destination_script_meth);
2517                 js_free(j_calls->get_shutdown_pubkey_meth);
2518                 js_free(j_calls->get_channel_signer_meth);
2519                 js_free(j_calls->get_secure_random_bytes_meth);
2520                 js_free(j_calls->read_chan_signer_meth);
2521                 js_free(j_calls->sign_invoice_meth);
2522                 FREE(j_calls);
2523         }
2524 }
2525 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2526         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2527         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2528         LDKSecretKey ret_ref;
2529         CHECK(*((uint32_t*)ret) == 32);
2530         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2531         return ret_ref;
2532 }
2533 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2534         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2535         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2536         LDKCVec_u8Z ret_ref;
2537         ret_ref.datalen = *((uint32_t*)ret);
2538         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2539         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2540         return ret_ref;
2541 }
2542 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
2543         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2544         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2545         LDKPublicKey ret_ref;
2546         CHECK(*((uint32_t*)ret) == 33);
2547         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2548         return ret_ref;
2549 }
2550 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2551         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2552         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2553         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2554         ret_conv = Sign_clone(ret);
2555         return ret_conv;
2556 }
2557 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2558         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2559         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2560         LDKThirtyTwoBytes ret_ref;
2561         CHECK(*((uint32_t*)ret) == 32);
2562         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2563         return ret_ref;
2564 }
2565 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2566         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2567         LDKu8slice reader_var = reader;
2568         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2569         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2570         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2571         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2572         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2573         return ret_conv;
2574 }
2575 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2576         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2577         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2578         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2579         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2580         CVec_u8Z_free(invoice_preimage_var);
2581         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2582         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2583         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2584         return ret_conv;
2585 }
2586 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2587         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2588         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2589         return (void*) this_arg;
2590 }
2591 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2592         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2593         atomic_init(&calls->refcnt, 1);
2594         //TODO: Assign calls->o from o
2595
2596         LDKKeysInterface ret = {
2597                 .this_arg = (void*) calls,
2598                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2599                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2600                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
2601                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2602                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2603                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2604                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2605                 .free = LDKKeysInterface_JCalls_free,
2606         };
2607         return ret;
2608 }
2609 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2610         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2611         *res_ptr = LDKKeysInterface_init(o);
2612         return (long)res_ptr;
2613 }
2614 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2615         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2616         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2617         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2618         return ret_arr;
2619 }
2620
2621 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2622         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2623         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2624         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2625         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2626         CVec_u8Z_free(ret_var);
2627         return ret_arr;
2628 }
2629
2630 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2631         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2632         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2633         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2634         return ret_arr;
2635 }
2636
2637 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2638         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2639         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2640         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2641         return (uint64_t)ret;
2642 }
2643
2644 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2645         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2646         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2647         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2648         return ret_arr;
2649 }
2650
2651 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2652         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2653         LDKu8slice reader_ref;
2654         reader_ref.datalen = *((uint32_t*)reader);
2655         reader_ref.data = (int8_t*)(reader + 4);
2656         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2657         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2658         return (uint64_t)ret_conv;
2659 }
2660
2661 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2662         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2663         LDKCVec_u8Z invoice_preimage_ref;
2664         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2665         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2666         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2667         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2668         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2669         return (uint64_t)ret_conv;
2670 }
2671
2672 typedef struct LDKFeeEstimator_JCalls {
2673         atomic_size_t refcnt;
2674         uint32_t get_est_sat_per_1000_weight_meth;
2675 } LDKFeeEstimator_JCalls;
2676 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2677         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2678         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2679                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2680                 FREE(j_calls);
2681         }
2682 }
2683 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2684         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2685         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2686         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2687 }
2688 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2689         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2690         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2691         return (void*) this_arg;
2692 }
2693 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2694         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2695         atomic_init(&calls->refcnt, 1);
2696         //TODO: Assign calls->o from o
2697
2698         LDKFeeEstimator ret = {
2699                 .this_arg = (void*) calls,
2700                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2701                 .free = LDKFeeEstimator_JCalls_free,
2702         };
2703         return ret;
2704 }
2705 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2706         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2707         *res_ptr = LDKFeeEstimator_init(o);
2708         return (long)res_ptr;
2709 }
2710 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2711         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2712         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2713         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2714         return ret_val;
2715 }
2716
2717 typedef struct LDKLogger_JCalls {
2718         atomic_size_t refcnt;
2719         uint32_t log_meth;
2720 } LDKLogger_JCalls;
2721 static void LDKLogger_JCalls_free(void* this_arg) {
2722         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2723         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2724                 js_free(j_calls->log_meth);
2725                 FREE(j_calls);
2726         }
2727 }
2728 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2729         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2730         const char* record_str = record;
2731         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2732         js_invoke_function_1(j_calls->log_meth, record_conv);
2733 }
2734 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2735         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2736         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2737         return (void*) this_arg;
2738 }
2739 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2740         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2741         atomic_init(&calls->refcnt, 1);
2742         //TODO: Assign calls->o from o
2743
2744         LDKLogger ret = {
2745                 .this_arg = (void*) calls,
2746                 .log = log_LDKLogger_jcall,
2747                 .free = LDKLogger_JCalls_free,
2748         };
2749         return ret;
2750 }
2751 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2752         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2753         *res_ptr = LDKLogger_init(o);
2754         return (long)res_ptr;
2755 }
2756 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2757         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2758         LDKThirtyTwoBytes a_ref;
2759         CHECK(*((uint32_t*)a) == 32);
2760         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2761         ret->a = a_ref;
2762         LDKChannelManager b_conv;
2763         b_conv.inner = (void*)(b & (~1));
2764         b_conv.is_owned = (b & 1) || (b == 0);
2765         // Warning: we need a move here but no clone is available for LDKChannelManager
2766         ret->b = b_conv;
2767         return (uint64_t)ret;
2768 }
2769 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2770         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2771         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2772         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2773         return a_arr;
2774 }
2775 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2776         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2777         LDKChannelManager b_var = tuple->b;
2778         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2779         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2780         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2781         return b_ref;
2782 }
2783 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2784         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2785 }
2786 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2787         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2788         CHECK(val->result_ok);
2789         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2790         return res_ref;
2791 }
2792 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2793         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2794         CHECK(!val->result_ok);
2795         LDKDecodeError err_var = (*val->contents.err);
2796         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2797         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2798         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2799         return err_ref;
2800 }
2801 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2802         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2803 }
2804 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2805         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2806         CHECK(val->result_ok);
2807         LDKChannelConfig res_var = (*val->contents.result);
2808         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2809         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2810         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2811         return res_ref;
2812 }
2813 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2814         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2815         CHECK(!val->result_ok);
2816         LDKDecodeError err_var = (*val->contents.err);
2817         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2818         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2819         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2820         return err_ref;
2821 }
2822 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2823         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2824 }
2825 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
2826         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2827         CHECK(val->result_ok);
2828         LDKOutPoint res_var = (*val->contents.result);
2829         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2830         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2831         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2832         return res_ref;
2833 }
2834 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
2835         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2836         CHECK(!val->result_ok);
2837         LDKDecodeError err_var = (*val->contents.err);
2838         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2839         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2840         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2841         return err_ref;
2842 }
2843 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
2844         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
2845 }
2846 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
2847         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2848         CHECK(val->result_ok);
2849         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
2850         return res_conv;
2851 }
2852 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
2853         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2854         CHECK(!val->result_ok);
2855         return *val->contents.err;
2856 }
2857 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
2858         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
2859 }
2860 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
2861         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2862         CHECK(val->result_ok);
2863         LDKInvoice res_var = (*val->contents.result);
2864         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2865         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2866         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2867         return res_ref;
2868 }
2869 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
2870         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2871         CHECK(!val->result_ok);
2872         return *val->contents.err;
2873 }
2874 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
2875         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
2876 }
2877 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
2878         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2879         CHECK(val->result_ok);
2880         LDKSignedRawInvoice res_var = (*val->contents.result);
2881         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2882         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2883         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2884         return res_ref;
2885 }
2886 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
2887         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2888         CHECK(!val->result_ok);
2889         return *val->contents.err;
2890 }
2891 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
2892         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
2893         LDKRawInvoice a_conv;
2894         a_conv.inner = (void*)(a & (~1));
2895         a_conv.is_owned = (a & 1) || (a == 0);
2896         a_conv = RawInvoice_clone(&a_conv);
2897         ret->a = a_conv;
2898         LDKThirtyTwoBytes b_ref;
2899         CHECK(*((uint32_t*)b) == 32);
2900         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2901         ret->b = b_ref;
2902         LDKInvoiceSignature c_conv;
2903         c_conv.inner = (void*)(c & (~1));
2904         c_conv.is_owned = (c & 1) || (c == 0);
2905         c_conv = InvoiceSignature_clone(&c_conv);
2906         ret->c = c_conv;
2907         return (uint64_t)ret;
2908 }
2909 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
2910         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2911         LDKRawInvoice a_var = tuple->a;
2912         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2913         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2914         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
2915         return a_ref;
2916 }
2917 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
2918         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2919         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2920         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2921         return b_arr;
2922 }
2923 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
2924         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2925         LDKInvoiceSignature c_var = tuple->c;
2926         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2927         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2928         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
2929         return c_ref;
2930 }
2931 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
2932         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
2933 }
2934 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
2935         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2936         CHECK(val->result_ok);
2937         LDKPayeePubKey res_var = (*val->contents.result);
2938         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2939         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2940         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2941         return res_ref;
2942 }
2943 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
2944         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2945         CHECK(!val->result_ok);
2946         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2947         return err_conv;
2948 }
2949 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
2950         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
2951         ret->datalen = *((uint32_t*)elems);
2952         if (ret->datalen == 0) {
2953                 ret->data = NULL;
2954         } else {
2955                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
2956                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2957                 for (size_t i = 0; i < ret->datalen; i++) {
2958                         uint32_t arr_elem = java_elems[i];
2959                         LDKPrivateRoute arr_elem_conv;
2960                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2961                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2962                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
2963                         ret->data[i] = arr_elem_conv;
2964                 }
2965         }
2966         return (uint64_t)ret;
2967 }
2968 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
2969         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
2970         for (size_t i = 0; i < ret.datalen; i++) {
2971                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
2972         }
2973         return ret;
2974 }
2975 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
2976         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
2977 }
2978 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
2979         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2980         CHECK(val->result_ok);
2981         LDKPositiveTimestamp res_var = (*val->contents.result);
2982         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2983         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2984         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2985         return res_ref;
2986 }
2987 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
2988         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2989         CHECK(!val->result_ok);
2990         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
2991         return err_conv;
2992 }
2993 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
2994         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
2995 }
2996 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
2997         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
2998         CHECK(val->result_ok);
2999         return *val->contents.result;
3000 }
3001 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3002         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3003         CHECK(!val->result_ok);
3004         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3005         return err_conv;
3006 }
3007 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3008         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3009 }
3010 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3011         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3012         CHECK(val->result_ok);
3013         LDKInvoice res_var = (*val->contents.result);
3014         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3015         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3016         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3017         return res_ref;
3018 }
3019 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3020         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3021         CHECK(!val->result_ok);
3022         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3023         return err_conv;
3024 }
3025 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3026         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3027 }
3028 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3029         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3030         CHECK(val->result_ok);
3031         LDKDescription res_var = (*val->contents.result);
3032         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3033         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3034         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3035         return res_ref;
3036 }
3037 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3038         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3039         CHECK(!val->result_ok);
3040         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3041         return err_conv;
3042 }
3043 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3044         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3045 }
3046 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3047         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3048         CHECK(val->result_ok);
3049         LDKExpiryTime res_var = (*val->contents.result);
3050         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3053         return res_ref;
3054 }
3055 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3056         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3057         CHECK(!val->result_ok);
3058         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3059         return err_conv;
3060 }
3061 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3062         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3063 }
3064 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3065         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3066         CHECK(val->result_ok);
3067         LDKPrivateRoute res_var = (*val->contents.result);
3068         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3069         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3070         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3071         return res_ref;
3072 }
3073 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3074         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3075         CHECK(!val->result_ok);
3076         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3077         return err_conv;
3078 }
3079 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3080         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3081 }
3082 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3083         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3084         CHECK(val->result_ok);
3085         LDKStr res_str = (*val->contents.result);
3086         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3087         return res_conv;
3088 }
3089 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3090         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3091         CHECK(!val->result_ok);
3092         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3093         return err_conv;
3094 }
3095 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3096         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3097 }
3098 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3099         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3100         CHECK(val->result_ok);
3101         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3102         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3103         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3104         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3105         return res_ref;
3106 }
3107 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3108         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3109         CHECK(!val->result_ok);
3110         LDKDecodeError err_var = (*val->contents.err);
3111         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3114         return err_ref;
3115 }
3116 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3117         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3118 }
3119 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3120         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3121         CHECK(val->result_ok);
3122         LDKHTLCUpdate res_var = (*val->contents.result);
3123         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3124         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3125         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3126         return res_ref;
3127 }
3128 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3129         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3130         CHECK(!val->result_ok);
3131         LDKDecodeError err_var = (*val->contents.err);
3132         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3133         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3134         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3135         return err_ref;
3136 }
3137 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3138         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3139 }
3140 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3141         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3142         CHECK(val->result_ok);
3143         return *val->contents.result;
3144 }
3145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3146         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3147         CHECK(!val->result_ok);
3148         LDKMonitorUpdateError err_var = (*val->contents.err);
3149         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3150         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3151         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3152         return err_ref;
3153 }
3154 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3155         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3156         LDKOutPoint a_conv;
3157         a_conv.inner = (void*)(a & (~1));
3158         a_conv.is_owned = (a & 1) || (a == 0);
3159         a_conv = OutPoint_clone(&a_conv);
3160         ret->a = a_conv;
3161         LDKCVec_u8Z b_ref;
3162         b_ref.datalen = *((uint32_t*)b);
3163         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3164         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3165         ret->b = b_ref;
3166         return (uint64_t)ret;
3167 }
3168 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3169         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3170         LDKOutPoint a_var = tuple->a;
3171         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3172         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3173         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3174         return a_ref;
3175 }
3176 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3177         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3178         LDKCVec_u8Z b_var = tuple->b;
3179         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3180         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3181         return b_arr;
3182 }
3183 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3184         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3185         ret->a = a;
3186         LDKCVec_u8Z b_ref;
3187         b_ref.datalen = *((uint32_t*)b);
3188         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3189         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3190         ret->b = b_ref;
3191         return (uint64_t)ret;
3192 }
3193 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3194         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3195         return tuple->a;
3196 }
3197 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3198         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3199         LDKCVec_u8Z b_var = tuple->b;
3200         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3201         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3202         return b_arr;
3203 }
3204 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3205         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3206         ret->datalen = *((uint32_t*)elems);
3207         if (ret->datalen == 0) {
3208                 ret->data = NULL;
3209         } else {
3210                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3211                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3212                 for (size_t i = 0; i < ret->datalen; i++) {
3213                         uint32_t arr_elem = java_elems[i];
3214                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3215                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3216                         ret->data[i] = arr_elem_conv;
3217                 }
3218         }
3219         return (uint64_t)ret;
3220 }
3221 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3222         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3223         for (size_t i = 0; i < ret.datalen; i++) {
3224                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3225         }
3226         return ret;
3227 }
3228 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3229         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3230         LDKThirtyTwoBytes a_ref;
3231         CHECK(*((uint32_t*)a) == 32);
3232         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3233         ret->a = a_ref;
3234         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3235         b_constr.datalen = *((uint32_t*)b);
3236         if (b_constr.datalen > 0)
3237                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3238         else
3239                 b_constr.data = NULL;
3240         uint32_t* b_vals = (uint32_t*)(b + 4);
3241         for (size_t e = 0; e < b_constr.datalen; e++) {
3242                 uint32_t b_conv_30 = b_vals[e];
3243                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3244                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3245                 b_constr.data[e] = b_conv_30_conv;
3246         }
3247         ret->b = b_constr;
3248         return (uint64_t)ret;
3249 }
3250 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3251         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3252         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3253         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3254         return a_arr;
3255 }
3256 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3257         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3258         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3259         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3260         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3261         for (size_t e = 0; e < b_var.datalen; e++) {
3262                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3263                 b_arr_ptr[e] = b_conv_30_ref;
3264         }
3265         return b_arr;
3266 }
3267 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3268         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3269         ret->datalen = *((uint32_t*)elems);
3270         if (ret->datalen == 0) {
3271                 ret->data = NULL;
3272         } else {
3273                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3274                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3275                 for (size_t i = 0; i < ret->datalen; i++) {
3276                         uint32_t arr_elem = java_elems[i];
3277                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3278                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3279                         ret->data[i] = arr_elem_conv;
3280                 }
3281         }
3282         return (uint64_t)ret;
3283 }
3284 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3285         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
3286         for (size_t i = 0; i < ret.datalen; i++) {
3287                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3288         }
3289         return ret;
3290 }
3291 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3292         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3293         switch(obj->tag) {
3294                 case LDKEvent_FundingGenerationReady: {
3295                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3296                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3297                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3298                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3299                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3300                         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;
3301                 }
3302                 case LDKEvent_PaymentReceived: {
3303                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3304                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3305                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3306                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_received.payment_preimage.data, 32);
3307                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3308                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
3309                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->payment_received.amt; (void) obj->payment_received.user_payment_id;
3310                 }
3311                 case LDKEvent_PaymentSent: {
3312                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3313                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3314                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3315                 }
3316                 case LDKEvent_PaymentFailed: {
3317                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3318                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
3319                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
3320                 }
3321                 case LDKEvent_PendingHTLCsForwardable: {
3322                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3323                 }
3324                 case LDKEvent_SpendableOutputs: {
3325                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3326                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3327                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3328                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3329                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3330                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3331                         }
3332                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3333                 }
3334                 default: abort();
3335         }
3336 }
3337 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3338         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3339         ret->datalen = *((uint32_t*)elems);
3340         if (ret->datalen == 0) {
3341                 ret->data = NULL;
3342         } else {
3343                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3344                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3345                 for (size_t i = 0; i < ret->datalen; i++) {
3346                         uint32_t arr_elem = java_elems[i];
3347                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3348                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3349                         ret->data[i] = arr_elem_conv;
3350                 }
3351         }
3352         return (uint64_t)ret;
3353 }
3354 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3355         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3356         for (size_t i = 0; i < ret.datalen; i++) {
3357                 ret.data[i] = Event_clone(&orig->data[i]);
3358         }
3359         return ret;
3360 }
3361 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3362         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3363         ret->a = a;
3364         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3365         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3366         ret->b = b_conv;
3367         return (uint64_t)ret;
3368 }
3369 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3370         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3371         return tuple->a;
3372 }
3373 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3374         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3375         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3376         return (uint64_t)b_ref;
3377 }
3378 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3379         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3380         ret->datalen = *((uint32_t*)elems);
3381         if (ret->datalen == 0) {
3382                 ret->data = NULL;
3383         } else {
3384                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3385                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3386                 for (size_t i = 0; i < ret->datalen; i++) {
3387                         uint32_t arr_elem = java_elems[i];
3388                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3389                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3390                         ret->data[i] = arr_elem_conv;
3391                 }
3392         }
3393         return (uint64_t)ret;
3394 }
3395 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3396         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3397         for (size_t i = 0; i < ret.datalen; i++) {
3398                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3399         }
3400         return ret;
3401 }
3402 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3403         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3404         LDKThirtyTwoBytes a_ref;
3405         CHECK(*((uint32_t*)a) == 32);
3406         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3407         ret->a = a_ref;
3408         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3409         b_constr.datalen = *((uint32_t*)b);
3410         if (b_constr.datalen > 0)
3411                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3412         else
3413                 b_constr.data = NULL;
3414         uint32_t* b_vals = (uint32_t*)(b + 4);
3415         for (size_t z = 0; z < b_constr.datalen; z++) {
3416                 uint32_t b_conv_25 = b_vals[z];
3417                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3418                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3419                 b_constr.data[z] = b_conv_25_conv;
3420         }
3421         ret->b = b_constr;
3422         return (uint64_t)ret;
3423 }
3424 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3425         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3426         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3427         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3428         return a_arr;
3429 }
3430 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3431         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3432         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3433         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3434         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3435         for (size_t z = 0; z < b_var.datalen; z++) {
3436                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3437                 b_arr_ptr[z] = b_conv_25_ref;
3438         }
3439         return b_arr;
3440 }
3441 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3442         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3443         ret->datalen = *((uint32_t*)elems);
3444         if (ret->datalen == 0) {
3445                 ret->data = NULL;
3446         } else {
3447                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3448                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3449                 for (size_t i = 0; i < ret->datalen; i++) {
3450                         uint32_t arr_elem = java_elems[i];
3451                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3452                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3453                         ret->data[i] = arr_elem_conv;
3454                 }
3455         }
3456         return (uint64_t)ret;
3457 }
3458 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3459         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
3460         for (size_t i = 0; i < ret.datalen; i++) {
3461                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3462         }
3463         return ret;
3464 }
3465 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3466         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3467 }
3468 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3469         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3470         CHECK(val->result_ok);
3471         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3472         return res_ref;
3473 }
3474 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3475         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3476         CHECK(!val->result_ok);
3477         LDKDecodeError err_var = (*val->contents.err);
3478         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3479         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3480         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3481         return err_ref;
3482 }
3483 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3484         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3485 }
3486 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3487         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3488         CHECK(val->result_ok);
3489         return *val->contents.result;
3490 }
3491 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3492         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3493         CHECK(!val->result_ok);
3494         LDKLightningError err_var = (*val->contents.err);
3495         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3496         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3497         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3498         return err_ref;
3499 }
3500 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3501         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3502         LDKChannelAnnouncement a_conv;
3503         a_conv.inner = (void*)(a & (~1));
3504         a_conv.is_owned = (a & 1) || (a == 0);
3505         a_conv = ChannelAnnouncement_clone(&a_conv);
3506         ret->a = a_conv;
3507         LDKChannelUpdate b_conv;
3508         b_conv.inner = (void*)(b & (~1));
3509         b_conv.is_owned = (b & 1) || (b == 0);
3510         b_conv = ChannelUpdate_clone(&b_conv);
3511         ret->b = b_conv;
3512         LDKChannelUpdate c_conv;
3513         c_conv.inner = (void*)(c & (~1));
3514         c_conv.is_owned = (c & 1) || (c == 0);
3515         c_conv = ChannelUpdate_clone(&c_conv);
3516         ret->c = c_conv;
3517         return (uint64_t)ret;
3518 }
3519 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3520         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3521         LDKChannelAnnouncement a_var = tuple->a;
3522         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3523         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3524         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3525         return a_ref;
3526 }
3527 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3528         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3529         LDKChannelUpdate b_var = tuple->b;
3530         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3531         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3532         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3533         return b_ref;
3534 }
3535 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3536         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3537         LDKChannelUpdate c_var = tuple->c;
3538         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3539         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3540         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3541         return c_ref;
3542 }
3543 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
3544         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3545         ret->datalen = *((uint32_t*)elems);
3546         if (ret->datalen == 0) {
3547                 ret->data = NULL;
3548         } else {
3549                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
3550                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3551                 for (size_t i = 0; i < ret->datalen; i++) {
3552                         uint32_t arr_elem = java_elems[i];
3553                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
3554                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
3555                         ret->data[i] = arr_elem_conv;
3556                 }
3557         }
3558         return (uint64_t)ret;
3559 }
3560 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3561         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3562         for (size_t i = 0; i < ret.datalen; i++) {
3563                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3564         }
3565         return ret;
3566 }
3567 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
3568         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3569         ret->datalen = *((uint32_t*)elems);
3570         if (ret->datalen == 0) {
3571                 ret->data = NULL;
3572         } else {
3573                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
3574                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3575                 for (size_t i = 0; i < ret->datalen; i++) {
3576                         uint32_t arr_elem = java_elems[i];
3577                         LDKNodeAnnouncement arr_elem_conv;
3578                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3579                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3580                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3581                         ret->data[i] = arr_elem_conv;
3582                 }
3583         }
3584         return (uint64_t)ret;
3585 }
3586 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3587         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3588         for (size_t i = 0; i < ret.datalen; i++) {
3589                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3590         }
3591         return ret;
3592 }
3593 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3594         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3595 }
3596 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3597         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3598         CHECK(val->result_ok);
3599         return *val->contents.result;
3600 }
3601 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3602         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3603         CHECK(!val->result_ok);
3604         LDKLightningError err_var = (*val->contents.err);
3605         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3606         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3607         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3608         return err_ref;
3609 }
3610 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
3611         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3612 }
3613 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
3614         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3615         CHECK(val->result_ok);
3616         LDKCVec_u8Z res_var = (*val->contents.result);
3617         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3618         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3619         return res_arr;
3620 }
3621 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
3622         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3623         CHECK(!val->result_ok);
3624         LDKPeerHandleError err_var = (*val->contents.err);
3625         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3626         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3627         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3628         return err_ref;
3629 }
3630 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
3631         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
3632 }
3633 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
3634         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3635         CHECK(val->result_ok);
3636         return *val->contents.result;
3637 }
3638 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
3639         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3640         CHECK(!val->result_ok);
3641         LDKPeerHandleError err_var = (*val->contents.err);
3642         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3643         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3644         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3645         return err_ref;
3646 }
3647 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
3648         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3649 }
3650 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
3651         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3652         CHECK(val->result_ok);
3653         return *val->contents.result;
3654 }
3655 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
3656         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3657         CHECK(!val->result_ok);
3658         LDKPeerHandleError err_var = (*val->contents.err);
3659         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3660         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3661         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3662         return err_ref;
3663 }
3664 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3665         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
3666 }
3667 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3668         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3669         CHECK(val->result_ok);
3670         LDKDirectionalChannelInfo res_var = (*val->contents.result);
3671         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3672         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3673         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3674         return res_ref;
3675 }
3676 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3677         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3678         CHECK(!val->result_ok);
3679         LDKDecodeError err_var = (*val->contents.err);
3680         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3681         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3682         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3683         return err_ref;
3684 }
3685 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3686         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
3687 }
3688 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3689         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3690         CHECK(val->result_ok);
3691         LDKChannelInfo res_var = (*val->contents.result);
3692         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3693         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3694         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3695         return res_ref;
3696 }
3697 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3698         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3699         CHECK(!val->result_ok);
3700         LDKDecodeError err_var = (*val->contents.err);
3701         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3702         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3703         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3704         return err_ref;
3705 }
3706 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
3707         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3708 }
3709 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3710         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3711         CHECK(val->result_ok);
3712         LDKRoutingFees res_var = (*val->contents.result);
3713         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3714         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3715         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3716         return res_ref;
3717 }
3718 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3719         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3720         CHECK(!val->result_ok);
3721         LDKDecodeError err_var = (*val->contents.err);
3722         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3723         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3724         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3725         return err_ref;
3726 }
3727 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3728         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3729 }
3730 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3731         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3732         CHECK(val->result_ok);
3733         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3734         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3735         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3736         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3737         return res_ref;
3738 }
3739 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3740         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3741         CHECK(!val->result_ok);
3742         LDKDecodeError err_var = (*val->contents.err);
3743         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3744         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3745         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3746         return err_ref;
3747 }
3748 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
3749         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
3750         ret->datalen = *((uint32_t*)elems);
3751         if (ret->datalen == 0) {
3752                 ret->data = NULL;
3753         } else {
3754                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
3755                 int64_t *java_elems = (int64_t*)(elems + 4);
3756                 for (size_t i = 0; i < ret->datalen; i++) {
3757                         ret->data[i] = java_elems[i];
3758                 }
3759         }
3760         return (uint64_t)ret;
3761 }
3762 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3763         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3764         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3765         return ret;
3766 }
3767 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3768         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3769 }
3770 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3771         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3772         CHECK(val->result_ok);
3773         LDKNodeInfo res_var = (*val->contents.result);
3774         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3775         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3776         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3777         return res_ref;
3778 }
3779 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3780         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3781         CHECK(!val->result_ok);
3782         LDKDecodeError err_var = (*val->contents.err);
3783         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3784         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3785         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3786         return err_ref;
3787 }
3788 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3789         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3790 }
3791 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3792         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3793         CHECK(val->result_ok);
3794         LDKNetworkGraph res_var = (*val->contents.result);
3795         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3796         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3797         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3798         return res_ref;
3799 }
3800 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3801         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3802         CHECK(!val->result_ok);
3803         LDKDecodeError err_var = (*val->contents.err);
3804         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3805         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3806         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3807         return err_ref;
3808 }
3809 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3810         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3811 }
3812 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3813         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3814         CHECK(val->result_ok);
3815         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3816         return res_ref;
3817 }
3818 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3819         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3820         CHECK(!val->result_ok);
3821         return *val->contents.err;
3822 }
3823 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3824         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3825 }
3826 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3827         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3828         CHECK(val->result_ok);
3829         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3830         *res_conv = (*val->contents.result);
3831         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3832         return (uint64_t)res_conv;
3833 }
3834 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3835         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3836         CHECK(!val->result_ok);
3837         LDKDecodeError err_var = (*val->contents.err);
3838         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3839         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3840         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3841         return err_ref;
3842 }
3843 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
3844         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
3845 }
3846 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
3847         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3848         CHECK(val->result_ok);
3849         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3850         return res_ref;
3851 }
3852 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
3853         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3854         CHECK(!val->result_ok);
3855         LDKDecodeError err_var = (*val->contents.err);
3856         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3857         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3858         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3859         return err_ref;
3860 }
3861 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3862         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3863         ret->datalen = *((uint32_t*)elems);
3864         if (ret->datalen == 0) {
3865                 ret->data = NULL;
3866         } else {
3867                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3868                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3869                 for (size_t i = 0; i < ret->datalen; i++) {
3870                         uint32_t arr_elem = java_elems[i];
3871                         LDKUpdateAddHTLC arr_elem_conv;
3872                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3873                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3874                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3875                         ret->data[i] = arr_elem_conv;
3876                 }
3877         }
3878         return (uint64_t)ret;
3879 }
3880 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3881         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3882         for (size_t i = 0; i < ret.datalen; i++) {
3883                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3884         }
3885         return ret;
3886 }
3887 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3888         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3889         ret->datalen = *((uint32_t*)elems);
3890         if (ret->datalen == 0) {
3891                 ret->data = NULL;
3892         } else {
3893                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3894                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3895                 for (size_t i = 0; i < ret->datalen; i++) {
3896                         uint32_t arr_elem = java_elems[i];
3897                         LDKUpdateFulfillHTLC arr_elem_conv;
3898                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3899                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3900                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3901                         ret->data[i] = arr_elem_conv;
3902                 }
3903         }
3904         return (uint64_t)ret;
3905 }
3906 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3907         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3908         for (size_t i = 0; i < ret.datalen; i++) {
3909                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3910         }
3911         return ret;
3912 }
3913 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3914         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3915         ret->datalen = *((uint32_t*)elems);
3916         if (ret->datalen == 0) {
3917                 ret->data = NULL;
3918         } else {
3919                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3920                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3921                 for (size_t i = 0; i < ret->datalen; i++) {
3922                         uint32_t arr_elem = java_elems[i];
3923                         LDKUpdateFailHTLC arr_elem_conv;
3924                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3925                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3926                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3927                         ret->data[i] = arr_elem_conv;
3928                 }
3929         }
3930         return (uint64_t)ret;
3931 }
3932 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3933         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3934         for (size_t i = 0; i < ret.datalen; i++) {
3935                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3936         }
3937         return ret;
3938 }
3939 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3940         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3941         ret->datalen = *((uint32_t*)elems);
3942         if (ret->datalen == 0) {
3943                 ret->data = NULL;
3944         } else {
3945                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3946                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3947                 for (size_t i = 0; i < ret->datalen; i++) {
3948                         uint32_t arr_elem = java_elems[i];
3949                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3950                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3951                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3952                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3953                         ret->data[i] = arr_elem_conv;
3954                 }
3955         }
3956         return (uint64_t)ret;
3957 }
3958 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3959         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3960         for (size_t i = 0; i < ret.datalen; i++) {
3961                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3962         }
3963         return ret;
3964 }
3965 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3966         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3967 }
3968 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3969         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3970         CHECK(val->result_ok);
3971         LDKAcceptChannel res_var = (*val->contents.result);
3972         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3973         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3974         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3975         return res_ref;
3976 }
3977 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3978         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3979         CHECK(!val->result_ok);
3980         LDKDecodeError err_var = (*val->contents.err);
3981         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3982         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3983         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3984         return err_ref;
3985 }
3986 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3987         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3988 }
3989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3990         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3991         CHECK(val->result_ok);
3992         LDKAnnouncementSignatures res_var = (*val->contents.result);
3993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3995         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3996         return res_ref;
3997 }
3998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3999         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4000         CHECK(!val->result_ok);
4001         LDKDecodeError err_var = (*val->contents.err);
4002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4004         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4005         return err_ref;
4006 }
4007 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4008         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4009 }
4010 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4011         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4012         CHECK(val->result_ok);
4013         LDKChannelReestablish res_var = (*val->contents.result);
4014         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4015         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4016         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4017         return res_ref;
4018 }
4019 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4020         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4021         CHECK(!val->result_ok);
4022         LDKDecodeError err_var = (*val->contents.err);
4023         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4026         return err_ref;
4027 }
4028 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4029         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4030 }
4031 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4032         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4033         CHECK(val->result_ok);
4034         LDKClosingSigned res_var = (*val->contents.result);
4035         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4036         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4037         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4038         return res_ref;
4039 }
4040 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4041         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4042         CHECK(!val->result_ok);
4043         LDKDecodeError err_var = (*val->contents.err);
4044         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4045         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4046         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4047         return err_ref;
4048 }
4049 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4050         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4051 }
4052 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4053         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4054         CHECK(val->result_ok);
4055         LDKCommitmentSigned res_var = (*val->contents.result);
4056         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4057         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4058         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4059         return res_ref;
4060 }
4061 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4062         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4063         CHECK(!val->result_ok);
4064         LDKDecodeError err_var = (*val->contents.err);
4065         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4066         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4067         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4068         return err_ref;
4069 }
4070 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4071         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4072 }
4073 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4074         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4075         CHECK(val->result_ok);
4076         LDKFundingCreated res_var = (*val->contents.result);
4077         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4078         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4079         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4080         return res_ref;
4081 }
4082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4083         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4084         CHECK(!val->result_ok);
4085         LDKDecodeError err_var = (*val->contents.err);
4086         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4087         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4088         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4089         return err_ref;
4090 }
4091 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4092         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4093 }
4094 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4095         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4096         CHECK(val->result_ok);
4097         LDKFundingSigned res_var = (*val->contents.result);
4098         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4099         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4100         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4101         return res_ref;
4102 }
4103 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4104         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4105         CHECK(!val->result_ok);
4106         LDKDecodeError err_var = (*val->contents.err);
4107         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4108         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4109         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4110         return err_ref;
4111 }
4112 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4113         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4114 }
4115 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4116         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4117         CHECK(val->result_ok);
4118         LDKFundingLocked res_var = (*val->contents.result);
4119         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4120         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4121         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4122         return res_ref;
4123 }
4124 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4125         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4126         CHECK(!val->result_ok);
4127         LDKDecodeError err_var = (*val->contents.err);
4128         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4129         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4130         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4131         return err_ref;
4132 }
4133 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4134         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4135 }
4136 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4137         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4138         CHECK(val->result_ok);
4139         LDKInit res_var = (*val->contents.result);
4140         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4141         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4142         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4143         return res_ref;
4144 }
4145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4146         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4147         CHECK(!val->result_ok);
4148         LDKDecodeError err_var = (*val->contents.err);
4149         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4150         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4151         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4152         return err_ref;
4153 }
4154 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4155         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4156 }
4157 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4158         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4159         CHECK(val->result_ok);
4160         LDKOpenChannel res_var = (*val->contents.result);
4161         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4162         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4163         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4164         return res_ref;
4165 }
4166 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4167         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4168         CHECK(!val->result_ok);
4169         LDKDecodeError err_var = (*val->contents.err);
4170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4173         return err_ref;
4174 }
4175 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4176         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4177 }
4178 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4179         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4180         CHECK(val->result_ok);
4181         LDKRevokeAndACK res_var = (*val->contents.result);
4182         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4185         return res_ref;
4186 }
4187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4188         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4189         CHECK(!val->result_ok);
4190         LDKDecodeError err_var = (*val->contents.err);
4191         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4192         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4193         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4194         return err_ref;
4195 }
4196 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4197         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4198 }
4199 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4200         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4201         CHECK(val->result_ok);
4202         LDKShutdown res_var = (*val->contents.result);
4203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4205         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4206         return res_ref;
4207 }
4208 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4209         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4210         CHECK(!val->result_ok);
4211         LDKDecodeError err_var = (*val->contents.err);
4212         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4213         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4214         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4215         return err_ref;
4216 }
4217 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4218         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4219 }
4220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4221         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4222         CHECK(val->result_ok);
4223         LDKUpdateFailHTLC res_var = (*val->contents.result);
4224         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4225         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4226         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4227         return res_ref;
4228 }
4229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4230         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4231         CHECK(!val->result_ok);
4232         LDKDecodeError err_var = (*val->contents.err);
4233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4235         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4236         return err_ref;
4237 }
4238 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4239         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4240 }
4241 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4242         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4243         CHECK(val->result_ok);
4244         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4245         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4246         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4247         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4248         return res_ref;
4249 }
4250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4251         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4252         CHECK(!val->result_ok);
4253         LDKDecodeError err_var = (*val->contents.err);
4254         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4257         return err_ref;
4258 }
4259 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4260         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4261 }
4262 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4263         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4264         CHECK(val->result_ok);
4265         LDKUpdateFee res_var = (*val->contents.result);
4266         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4267         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4268         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4269         return res_ref;
4270 }
4271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4272         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4273         CHECK(!val->result_ok);
4274         LDKDecodeError err_var = (*val->contents.err);
4275         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4276         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4277         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4278         return err_ref;
4279 }
4280 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4281         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4282 }
4283 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4284         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4285         CHECK(val->result_ok);
4286         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4287         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4288         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4289         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4290         return res_ref;
4291 }
4292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4293         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4294         CHECK(!val->result_ok);
4295         LDKDecodeError err_var = (*val->contents.err);
4296         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4297         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4298         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4299         return err_ref;
4300 }
4301 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4302         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4303 }
4304 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4305         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4306         CHECK(val->result_ok);
4307         LDKUpdateAddHTLC res_var = (*val->contents.result);
4308         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4309         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4310         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4311         return res_ref;
4312 }
4313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4314         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4315         CHECK(!val->result_ok);
4316         LDKDecodeError err_var = (*val->contents.err);
4317         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4318         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4319         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4320         return err_ref;
4321 }
4322 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4323         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4324 }
4325 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4326         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4327         CHECK(val->result_ok);
4328         LDKPing res_var = (*val->contents.result);
4329         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4330         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4331         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4332         return res_ref;
4333 }
4334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4335         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4336         CHECK(!val->result_ok);
4337         LDKDecodeError err_var = (*val->contents.err);
4338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4340         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4341         return err_ref;
4342 }
4343 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4344         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4345 }
4346 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4347         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4348         CHECK(val->result_ok);
4349         LDKPong res_var = (*val->contents.result);
4350         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4351         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4352         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4353         return res_ref;
4354 }
4355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4356         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4357         CHECK(!val->result_ok);
4358         LDKDecodeError err_var = (*val->contents.err);
4359         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4362         return err_ref;
4363 }
4364 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4365         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4366 }
4367 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4368         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4369         CHECK(val->result_ok);
4370         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4371         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4372         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4373         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4374         return res_ref;
4375 }
4376 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4377         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4378         CHECK(!val->result_ok);
4379         LDKDecodeError err_var = (*val->contents.err);
4380         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4381         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4382         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4383         return err_ref;
4384 }
4385 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4386         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4387 }
4388 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4389         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4390         CHECK(val->result_ok);
4391         LDKChannelAnnouncement res_var = (*val->contents.result);
4392         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4393         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4394         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4395         return res_ref;
4396 }
4397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4398         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4399         CHECK(!val->result_ok);
4400         LDKDecodeError err_var = (*val->contents.err);
4401         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4402         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4403         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4404         return err_ref;
4405 }
4406 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4407         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4408 }
4409 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4410         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4411         CHECK(val->result_ok);
4412         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4413         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4414         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4415         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4416         return res_ref;
4417 }
4418 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4419         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4420         CHECK(!val->result_ok);
4421         LDKDecodeError err_var = (*val->contents.err);
4422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4424         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4425         return err_ref;
4426 }
4427 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4428         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4429 }
4430 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4431         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4432         CHECK(val->result_ok);
4433         LDKChannelUpdate res_var = (*val->contents.result);
4434         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4435         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4436         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4437         return res_ref;
4438 }
4439 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4440         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4441         CHECK(!val->result_ok);
4442         LDKDecodeError err_var = (*val->contents.err);
4443         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4444         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4445         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4446         return err_ref;
4447 }
4448 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4449         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4450 }
4451 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4452         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4453         CHECK(val->result_ok);
4454         LDKErrorMessage res_var = (*val->contents.result);
4455         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4456         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4457         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4458         return res_ref;
4459 }
4460 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4461         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4462         CHECK(!val->result_ok);
4463         LDKDecodeError err_var = (*val->contents.err);
4464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4466         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4467         return err_ref;
4468 }
4469 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4470         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4471 }
4472 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4473         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4474         CHECK(val->result_ok);
4475         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4478         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4479         return res_ref;
4480 }
4481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4482         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4483         CHECK(!val->result_ok);
4484         LDKDecodeError err_var = (*val->contents.err);
4485         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4486         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4487         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4488         return err_ref;
4489 }
4490 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4491         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4492 }
4493 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4494         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4495         CHECK(val->result_ok);
4496         LDKNodeAnnouncement res_var = (*val->contents.result);
4497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4499         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4500         return res_ref;
4501 }
4502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4503         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4504         CHECK(!val->result_ok);
4505         LDKDecodeError err_var = (*val->contents.err);
4506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4508         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4509         return err_ref;
4510 }
4511 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
4512         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4513 }
4514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
4515         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4516         CHECK(val->result_ok);
4517         LDKQueryShortChannelIds res_var = (*val->contents.result);
4518         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4519         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4520         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4521         return res_ref;
4522 }
4523 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
4524         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4525         CHECK(!val->result_ok);
4526         LDKDecodeError err_var = (*val->contents.err);
4527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4529         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4530         return err_ref;
4531 }
4532 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
4533         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4534 }
4535 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
4536         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4537         CHECK(val->result_ok);
4538         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4541         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4542         return res_ref;
4543 }
4544 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
4545         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4546         CHECK(!val->result_ok);
4547         LDKDecodeError err_var = (*val->contents.err);
4548         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4551         return err_ref;
4552 }
4553 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4554         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4555 }
4556 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4557         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4558         CHECK(val->result_ok);
4559         LDKQueryChannelRange res_var = (*val->contents.result);
4560         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4561         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4562         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4563         return res_ref;
4564 }
4565 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4566         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4567         CHECK(!val->result_ok);
4568         LDKDecodeError err_var = (*val->contents.err);
4569         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4570         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4571         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4572         return err_ref;
4573 }
4574 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4575         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4576 }
4577 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4578         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4579         CHECK(val->result_ok);
4580         LDKReplyChannelRange res_var = (*val->contents.result);
4581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4584         return res_ref;
4585 }
4586 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4587         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4588         CHECK(!val->result_ok);
4589         LDKDecodeError err_var = (*val->contents.err);
4590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4593         return err_ref;
4594 }
4595 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
4596         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4597 }
4598 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
4599         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4600         CHECK(val->result_ok);
4601         LDKGossipTimestampFilter res_var = (*val->contents.result);
4602         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4603         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4604         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4605         return res_ref;
4606 }
4607 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
4608         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4609         CHECK(!val->result_ok);
4610         LDKDecodeError err_var = (*val->contents.err);
4611         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4612         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4613         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4614         return err_ref;
4615 }
4616 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
4617         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
4618         switch(obj->tag) {
4619                 case LDKSignOrCreationError_SignError: {
4620                         return 0 /* LDKSignOrCreationError - SignError */;
4621                 }
4622                 case LDKSignOrCreationError_CreationError: {
4623                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
4624                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
4625                 }
4626                 default: abort();
4627         }
4628 }
4629 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
4630         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
4631 }
4632 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
4633         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4634         CHECK(val->result_ok);
4635         LDKInvoice res_var = (*val->contents.result);
4636         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4637         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4638         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4639         return res_ref;
4640 }
4641 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
4642         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4643         CHECK(!val->result_ok);
4644         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4645         return err_ref;
4646 }
4647 typedef struct LDKMessageSendEventsProvider_JCalls {
4648         atomic_size_t refcnt;
4649         uint32_t get_and_clear_pending_msg_events_meth;
4650 } LDKMessageSendEventsProvider_JCalls;
4651 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4652         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4653         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4654                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4655                 FREE(j_calls);
4656         }
4657 }
4658 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4659         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4660         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4661         LDKCVec_MessageSendEventZ ret_constr;
4662         ret_constr.datalen = *((uint32_t*)ret);
4663         if (ret_constr.datalen > 0)
4664                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4665         else
4666                 ret_constr.data = NULL;
4667         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4668         for (size_t s = 0; s < ret_constr.datalen; s++) {
4669                 uint32_t ret_conv_18 = ret_vals[s];
4670                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4671                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4672                 ret_constr.data[s] = ret_conv_18_conv;
4673         }
4674         return ret_constr;
4675 }
4676 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4677         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4678         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4679         return (void*) this_arg;
4680 }
4681 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4682         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4683         atomic_init(&calls->refcnt, 1);
4684         //TODO: Assign calls->o from o
4685
4686         LDKMessageSendEventsProvider ret = {
4687                 .this_arg = (void*) calls,
4688                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4689                 .free = LDKMessageSendEventsProvider_JCalls_free,
4690         };
4691         return ret;
4692 }
4693 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4694         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4695         *res_ptr = LDKMessageSendEventsProvider_init(o);
4696         return (long)res_ptr;
4697 }
4698 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4699         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4700         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4701         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4702         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4703         for (size_t s = 0; s < ret_var.datalen; s++) {
4704                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4705                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4706                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
4707                 ret_arr_ptr[s] = ret_conv_18_ref;
4708         }
4709         FREE(ret_var.data);
4710         return ret_arr;
4711 }
4712
4713 typedef struct LDKEventHandler_JCalls {
4714         atomic_size_t refcnt;
4715         uint32_t handle_event_meth;
4716 } LDKEventHandler_JCalls;
4717 static void LDKEventHandler_JCalls_free(void* this_arg) {
4718         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4719         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4720                 js_free(j_calls->handle_event_meth);
4721                 FREE(j_calls);
4722         }
4723 }
4724 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
4725         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4726         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4727         *event_copy = event;
4728         uint64_t event_ref = (uint64_t)event_copy;
4729         js_invoke_function_1(j_calls->handle_event_meth, event_ref);
4730 }
4731 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
4732         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4733         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4734         return (void*) this_arg;
4735 }
4736 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
4737         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
4738         atomic_init(&calls->refcnt, 1);
4739         //TODO: Assign calls->o from o
4740
4741         LDKEventHandler ret = {
4742                 .this_arg = (void*) calls,
4743                 .handle_event = handle_event_LDKEventHandler_jcall,
4744                 .free = LDKEventHandler_JCalls_free,
4745         };
4746         return ret;
4747 }
4748 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
4749         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4750         *res_ptr = LDKEventHandler_init(o);
4751         return (long)res_ptr;
4752 }
4753 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
4754         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
4755         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
4756         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
4757 }
4758
4759 typedef struct LDKEventsProvider_JCalls {
4760         atomic_size_t refcnt;
4761         uint32_t process_pending_events_meth;
4762 } LDKEventsProvider_JCalls;
4763 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4764         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4765         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4766                 js_free(j_calls->process_pending_events_meth);
4767                 FREE(j_calls);
4768         }
4769 }
4770 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
4771         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4772         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4773         *ret = handler;
4774         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret);
4775 }
4776 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4777         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4778         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4779         return (void*) this_arg;
4780 }
4781 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4782         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4783         atomic_init(&calls->refcnt, 1);
4784         //TODO: Assign calls->o from o
4785
4786         LDKEventsProvider ret = {
4787                 .this_arg = (void*) calls,
4788                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
4789                 .free = LDKEventsProvider_JCalls_free,
4790         };
4791         return ret;
4792 }
4793 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4794         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4795         *res_ptr = LDKEventsProvider_init(o);
4796         return (long)res_ptr;
4797 }
4798 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
4799         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4800         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
4801         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
4802 }
4803
4804 typedef struct LDKAccess_JCalls {
4805         atomic_size_t refcnt;
4806         uint32_t get_utxo_meth;
4807 } LDKAccess_JCalls;
4808 static void LDKAccess_JCalls_free(void* this_arg) {
4809         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4810         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4811                 js_free(j_calls->get_utxo_meth);
4812                 FREE(j_calls);
4813         }
4814 }
4815 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4816         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4817         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4818         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4819         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4820         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4821         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4822         return ret_conv;
4823 }
4824 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4825         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4826         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4827         return (void*) this_arg;
4828 }
4829 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4830         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4831         atomic_init(&calls->refcnt, 1);
4832         //TODO: Assign calls->o from o
4833
4834         LDKAccess ret = {
4835                 .this_arg = (void*) calls,
4836                 .get_utxo = get_utxo_LDKAccess_jcall,
4837                 .free = LDKAccess_JCalls_free,
4838         };
4839         return ret;
4840 }
4841 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4842         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4843         *res_ptr = LDKAccess_init(o);
4844         return (long)res_ptr;
4845 }
4846 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4847         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4848         unsigned char genesis_hash_arr[32];
4849         CHECK(*((uint32_t*)genesis_hash) == 32);
4850         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4851         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4852         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4853         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4854         return (uint64_t)ret_conv;
4855 }
4856
4857 typedef struct LDKListen_JCalls {
4858         atomic_size_t refcnt;
4859         uint32_t block_connected_meth;
4860         uint32_t block_disconnected_meth;
4861 } LDKListen_JCalls;
4862 static void LDKListen_JCalls_free(void* this_arg) {
4863         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4864         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4865                 js_free(j_calls->block_connected_meth);
4866                 js_free(j_calls->block_disconnected_meth);
4867                 FREE(j_calls);
4868         }
4869 }
4870 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4871         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4872         LDKu8slice block_var = block;
4873         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4874         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4875         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4876 }
4877 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4878         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4879         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4880         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4881         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4882 }
4883 static void* LDKListen_JCalls_clone(const void* this_arg) {
4884         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4885         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4886         return (void*) this_arg;
4887 }
4888 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4889         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4890         atomic_init(&calls->refcnt, 1);
4891         //TODO: Assign calls->o from o
4892
4893         LDKListen ret = {
4894                 .this_arg = (void*) calls,
4895                 .block_connected = block_connected_LDKListen_jcall,
4896                 .block_disconnected = block_disconnected_LDKListen_jcall,
4897                 .free = LDKListen_JCalls_free,
4898         };
4899         return ret;
4900 }
4901 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4902         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4903         *res_ptr = LDKListen_init(o);
4904         return (long)res_ptr;
4905 }
4906 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4907         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4908         LDKu8slice block_ref;
4909         block_ref.datalen = *((uint32_t*)block);
4910         block_ref.data = (int8_t*)(block + 4);
4911         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4912 }
4913
4914 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4915         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4916         unsigned char header_arr[80];
4917         CHECK(*((uint32_t*)header) == 80);
4918         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4919         unsigned char (*header_ref)[80] = &header_arr;
4920         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4921 }
4922
4923 typedef struct LDKConfirm_JCalls {
4924         atomic_size_t refcnt;
4925         uint32_t transactions_confirmed_meth;
4926         uint32_t transaction_unconfirmed_meth;
4927         uint32_t best_block_updated_meth;
4928         uint32_t get_relevant_txids_meth;
4929 } LDKConfirm_JCalls;
4930 static void LDKConfirm_JCalls_free(void* this_arg) {
4931         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4932         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4933                 js_free(j_calls->transactions_confirmed_meth);
4934                 js_free(j_calls->transaction_unconfirmed_meth);
4935                 js_free(j_calls->best_block_updated_meth);
4936                 js_free(j_calls->get_relevant_txids_meth);
4937                 FREE(j_calls);
4938         }
4939 }
4940 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
4941         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4942         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4943         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4944         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
4945         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4946         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
4947         for (size_t e = 0; e < txdata_var.datalen; e++) {
4948                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4949                 *txdata_conv_30_ref = txdata_var.data[e];
4950                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
4951         }
4952         FREE(txdata_var.data);
4953         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
4954 }
4955 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
4956         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4957         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4958         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4959         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
4960 }
4961 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4962         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4963         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4964         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4965         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
4966 }
4967 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
4968         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4969         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
4970         LDKCVec_TxidZ ret_constr;
4971         ret_constr.datalen = *((uint32_t*)ret);
4972         if (ret_constr.datalen > 0)
4973                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
4974         else
4975                 ret_constr.data = NULL;
4976         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
4977         for (size_t m = 0; m < ret_constr.datalen; m++) {
4978                 int8_tArray ret_conv_12 = ret_vals[m];
4979                 LDKThirtyTwoBytes ret_conv_12_ref;
4980                 CHECK(*((uint32_t*)ret_conv_12) == 32);
4981                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
4982                 ret_constr.data[m] = ret_conv_12_ref;
4983         }
4984         return ret_constr;
4985 }
4986 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
4987         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4988         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4989         return (void*) this_arg;
4990 }
4991 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
4992         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
4993         atomic_init(&calls->refcnt, 1);
4994         //TODO: Assign calls->o from o
4995
4996         LDKConfirm ret = {
4997                 .this_arg = (void*) calls,
4998                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
4999                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5000                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5001                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5002                 .free = LDKConfirm_JCalls_free,
5003         };
5004         return ret;
5005 }
5006 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5007         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5008         *res_ptr = LDKConfirm_init(o);
5009         return (long)res_ptr;
5010 }
5011 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5012         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5013         unsigned char header_arr[80];
5014         CHECK(*((uint32_t*)header) == 80);
5015         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5016         unsigned char (*header_ref)[80] = &header_arr;
5017         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5018         txdata_constr.datalen = *((uint32_t*)txdata);
5019         if (txdata_constr.datalen > 0)
5020                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5021         else
5022                 txdata_constr.data = NULL;
5023         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5024         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5025                 uint32_t txdata_conv_30 = txdata_vals[e];
5026                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5027                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5028                 txdata_constr.data[e] = txdata_conv_30_conv;
5029         }
5030         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5031 }
5032
5033 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5034         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5035         unsigned char txid_arr[32];
5036         CHECK(*((uint32_t*)txid) == 32);
5037         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5038         unsigned char (*txid_ref)[32] = &txid_arr;
5039         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5040 }
5041
5042 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5043         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5044         unsigned char header_arr[80];
5045         CHECK(*((uint32_t*)header) == 80);
5046         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5047         unsigned char (*header_ref)[80] = &header_arr;
5048         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5049 }
5050
5051 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5052         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5053         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5054         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5055         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5056         for (size_t m = 0; m < ret_var.datalen; m++) {
5057                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5058                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5059                 ret_arr_ptr[m] = ret_conv_12_arr;
5060         }
5061         FREE(ret_var.data);
5062         return ret_arr;
5063 }
5064
5065 typedef struct LDKFilter_JCalls {
5066         atomic_size_t refcnt;
5067         uint32_t register_tx_meth;
5068         uint32_t register_output_meth;
5069 } LDKFilter_JCalls;
5070 static void LDKFilter_JCalls_free(void* this_arg) {
5071         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5072         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5073                 js_free(j_calls->register_tx_meth);
5074                 js_free(j_calls->register_output_meth);
5075                 FREE(j_calls);
5076         }
5077 }
5078 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5079         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5080         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5081         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5082         LDKu8slice script_pubkey_var = script_pubkey;
5083         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5084         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5085         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5086 }
5087 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5088         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5089         LDKWatchedOutput output_var = output;
5090         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5091         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5092         uint64_t output_ref = (uint64_t)output_var.inner;
5093         if (output_var.is_owned) {
5094                 output_ref |= 1;
5095         }
5096         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
5097         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5098         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5099         return ret_conv;
5100 }
5101 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5102         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5103         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5104         return (void*) this_arg;
5105 }
5106 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5107         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5108         atomic_init(&calls->refcnt, 1);
5109         //TODO: Assign calls->o from o
5110
5111         LDKFilter ret = {
5112                 .this_arg = (void*) calls,
5113                 .register_tx = register_tx_LDKFilter_jcall,
5114                 .register_output = register_output_LDKFilter_jcall,
5115                 .free = LDKFilter_JCalls_free,
5116         };
5117         return ret;
5118 }
5119 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5120         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5121         *res_ptr = LDKFilter_init(o);
5122         return (long)res_ptr;
5123 }
5124 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5125         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5126         unsigned char txid_arr[32];
5127         CHECK(*((uint32_t*)txid) == 32);
5128         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5129         unsigned char (*txid_ref)[32] = &txid_arr;
5130         LDKu8slice script_pubkey_ref;
5131         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5132         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5133         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5134 }
5135
5136 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5137         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5138         LDKWatchedOutput output_conv;
5139         output_conv.inner = (void*)(output & (~1));
5140         output_conv.is_owned = (output & 1) || (output == 0);
5141         output_conv = WatchedOutput_clone(&output_conv);
5142         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5143         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5144         uint64_t ret_ref = (uint64_t)ret_copy;
5145         return ret_ref;
5146 }
5147
5148 typedef struct LDKPersist_JCalls {
5149         atomic_size_t refcnt;
5150         uint32_t persist_new_channel_meth;
5151         uint32_t update_persisted_channel_meth;
5152 } LDKPersist_JCalls;
5153 static void LDKPersist_JCalls_free(void* this_arg) {
5154         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5155         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5156                 js_free(j_calls->persist_new_channel_meth);
5157                 js_free(j_calls->update_persisted_channel_meth);
5158                 FREE(j_calls);
5159         }
5160 }
5161 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5162         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5163         LDKOutPoint id_var = id;
5164         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5165         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5166         uint64_t id_ref = (uint64_t)id_var.inner;
5167         if (id_var.is_owned) {
5168                 id_ref |= 1;
5169         }
5170         LDKChannelMonitor data_var = *data;
5171         data_var = ChannelMonitor_clone(data);
5172         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5173         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5174         uint64_t data_ref = (uint64_t)data_var.inner;
5175         if (data_var.is_owned) {
5176                 data_ref |= 1;
5177         }
5178         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5179         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5180         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5181         return ret_conv;
5182 }
5183 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5184         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5185         LDKOutPoint id_var = id;
5186         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5187         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5188         uint64_t id_ref = (uint64_t)id_var.inner;
5189         if (id_var.is_owned) {
5190                 id_ref |= 1;
5191         }
5192         LDKChannelMonitorUpdate update_var = *update;
5193         update_var = ChannelMonitorUpdate_clone(update);
5194         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5195         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5196         uint64_t update_ref = (uint64_t)update_var.inner;
5197         if (update_var.is_owned) {
5198                 update_ref |= 1;
5199         }
5200         LDKChannelMonitor data_var = *data;
5201         data_var = ChannelMonitor_clone(data);
5202         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5203         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5204         uint64_t data_ref = (uint64_t)data_var.inner;
5205         if (data_var.is_owned) {
5206                 data_ref |= 1;
5207         }
5208         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5209         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5210         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5211         return ret_conv;
5212 }
5213 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5214         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5215         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5216         return (void*) this_arg;
5217 }
5218 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5219         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5220         atomic_init(&calls->refcnt, 1);
5221         //TODO: Assign calls->o from o
5222
5223         LDKPersist ret = {
5224                 .this_arg = (void*) calls,
5225                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5226                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5227                 .free = LDKPersist_JCalls_free,
5228         };
5229         return ret;
5230 }
5231 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5232         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5233         *res_ptr = LDKPersist_init(o);
5234         return (long)res_ptr;
5235 }
5236 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5237         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5238         LDKOutPoint id_conv;
5239         id_conv.inner = (void*)(id & (~1));
5240         id_conv.is_owned = (id & 1) || (id == 0);
5241         id_conv = OutPoint_clone(&id_conv);
5242         LDKChannelMonitor data_conv;
5243         data_conv.inner = (void*)(data & (~1));
5244         data_conv.is_owned = false;
5245         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5246         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5247         return (uint64_t)ret_conv;
5248 }
5249
5250 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5251         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5252         LDKOutPoint id_conv;
5253         id_conv.inner = (void*)(id & (~1));
5254         id_conv.is_owned = (id & 1) || (id == 0);
5255         id_conv = OutPoint_clone(&id_conv);
5256         LDKChannelMonitorUpdate update_conv;
5257         update_conv.inner = (void*)(update & (~1));
5258         update_conv.is_owned = false;
5259         LDKChannelMonitor data_conv;
5260         data_conv.inner = (void*)(data & (~1));
5261         data_conv.is_owned = false;
5262         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5263         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5264         return (uint64_t)ret_conv;
5265 }
5266
5267 typedef struct LDKChannelMessageHandler_JCalls {
5268         atomic_size_t refcnt;
5269         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5270         uint32_t handle_open_channel_meth;
5271         uint32_t handle_accept_channel_meth;
5272         uint32_t handle_funding_created_meth;
5273         uint32_t handle_funding_signed_meth;
5274         uint32_t handle_funding_locked_meth;
5275         uint32_t handle_shutdown_meth;
5276         uint32_t handle_closing_signed_meth;
5277         uint32_t handle_update_add_htlc_meth;
5278         uint32_t handle_update_fulfill_htlc_meth;
5279         uint32_t handle_update_fail_htlc_meth;
5280         uint32_t handle_update_fail_malformed_htlc_meth;
5281         uint32_t handle_commitment_signed_meth;
5282         uint32_t handle_revoke_and_ack_meth;
5283         uint32_t handle_update_fee_meth;
5284         uint32_t handle_announcement_signatures_meth;
5285         uint32_t peer_disconnected_meth;
5286         uint32_t peer_connected_meth;
5287         uint32_t handle_channel_reestablish_meth;
5288         uint32_t handle_channel_update_meth;
5289         uint32_t handle_error_meth;
5290 } LDKChannelMessageHandler_JCalls;
5291 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5292         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5293         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5294                 js_free(j_calls->handle_open_channel_meth);
5295                 js_free(j_calls->handle_accept_channel_meth);
5296                 js_free(j_calls->handle_funding_created_meth);
5297                 js_free(j_calls->handle_funding_signed_meth);
5298                 js_free(j_calls->handle_funding_locked_meth);
5299                 js_free(j_calls->handle_shutdown_meth);
5300                 js_free(j_calls->handle_closing_signed_meth);
5301                 js_free(j_calls->handle_update_add_htlc_meth);
5302                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5303                 js_free(j_calls->handle_update_fail_htlc_meth);
5304                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5305                 js_free(j_calls->handle_commitment_signed_meth);
5306                 js_free(j_calls->handle_revoke_and_ack_meth);
5307                 js_free(j_calls->handle_update_fee_meth);
5308                 js_free(j_calls->handle_announcement_signatures_meth);
5309                 js_free(j_calls->peer_disconnected_meth);
5310                 js_free(j_calls->peer_connected_meth);
5311                 js_free(j_calls->handle_channel_reestablish_meth);
5312                 js_free(j_calls->handle_channel_update_meth);
5313                 js_free(j_calls->handle_error_meth);
5314                 FREE(j_calls);
5315         }
5316 }
5317 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5318         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5319         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5320         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5321         LDKInitFeatures their_features_var = their_features;
5322         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5323         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5324         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5325         if (their_features_var.is_owned) {
5326                 their_features_ref |= 1;
5327         }
5328         LDKOpenChannel msg_var = *msg;
5329         msg_var = OpenChannel_clone(msg);
5330         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5331         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5332         uint64_t msg_ref = (uint64_t)msg_var.inner;
5333         if (msg_var.is_owned) {
5334                 msg_ref |= 1;
5335         }
5336         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5337 }
5338 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5339         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5340         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5341         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5342         LDKInitFeatures their_features_var = their_features;
5343         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5344         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5345         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5346         if (their_features_var.is_owned) {
5347                 their_features_ref |= 1;
5348         }
5349         LDKAcceptChannel msg_var = *msg;
5350         msg_var = AcceptChannel_clone(msg);
5351         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5352         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5353         uint64_t msg_ref = (uint64_t)msg_var.inner;
5354         if (msg_var.is_owned) {
5355                 msg_ref |= 1;
5356         }
5357         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5358 }
5359 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5360         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5361         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5362         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5363         LDKFundingCreated msg_var = *msg;
5364         msg_var = FundingCreated_clone(msg);
5365         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5366         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5367         uint64_t msg_ref = (uint64_t)msg_var.inner;
5368         if (msg_var.is_owned) {
5369                 msg_ref |= 1;
5370         }
5371         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5372 }
5373 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5374         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5375         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5376         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5377         LDKFundingSigned msg_var = *msg;
5378         msg_var = FundingSigned_clone(msg);
5379         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5380         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5381         uint64_t msg_ref = (uint64_t)msg_var.inner;
5382         if (msg_var.is_owned) {
5383                 msg_ref |= 1;
5384         }
5385         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5386 }
5387 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5388         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5389         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5390         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5391         LDKFundingLocked msg_var = *msg;
5392         msg_var = FundingLocked_clone(msg);
5393         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5394         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5395         uint64_t msg_ref = (uint64_t)msg_var.inner;
5396         if (msg_var.is_owned) {
5397                 msg_ref |= 1;
5398         }
5399         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5400 }
5401 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5402         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5403         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5404         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5405         LDKInitFeatures their_features_var = *their_features;
5406         their_features_var = InitFeatures_clone(their_features);
5407         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5408         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5409         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5410         if (their_features_var.is_owned) {
5411                 their_features_ref |= 1;
5412         }
5413         LDKShutdown msg_var = *msg;
5414         msg_var = Shutdown_clone(msg);
5415         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5416         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5417         uint64_t msg_ref = (uint64_t)msg_var.inner;
5418         if (msg_var.is_owned) {
5419                 msg_ref |= 1;
5420         }
5421         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5422 }
5423 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5424         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5425         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5426         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5427         LDKClosingSigned msg_var = *msg;
5428         msg_var = ClosingSigned_clone(msg);
5429         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5430         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5431         uint64_t msg_ref = (uint64_t)msg_var.inner;
5432         if (msg_var.is_owned) {
5433                 msg_ref |= 1;
5434         }
5435         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5436 }
5437 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5438         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5439         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5440         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5441         LDKUpdateAddHTLC msg_var = *msg;
5442         msg_var = UpdateAddHTLC_clone(msg);
5443         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         uint64_t msg_ref = (uint64_t)msg_var.inner;
5446         if (msg_var.is_owned) {
5447                 msg_ref |= 1;
5448         }
5449         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5450 }
5451 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5452         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5453         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5454         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5455         LDKUpdateFulfillHTLC msg_var = *msg;
5456         msg_var = UpdateFulfillHTLC_clone(msg);
5457         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5458         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5459         uint64_t msg_ref = (uint64_t)msg_var.inner;
5460         if (msg_var.is_owned) {
5461                 msg_ref |= 1;
5462         }
5463         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5464 }
5465 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5466         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5467         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5468         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5469         LDKUpdateFailHTLC msg_var = *msg;
5470         msg_var = UpdateFailHTLC_clone(msg);
5471         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5472         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5473         uint64_t msg_ref = (uint64_t)msg_var.inner;
5474         if (msg_var.is_owned) {
5475                 msg_ref |= 1;
5476         }
5477         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5478 }
5479 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5481         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5482         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5483         LDKUpdateFailMalformedHTLC msg_var = *msg;
5484         msg_var = UpdateFailMalformedHTLC_clone(msg);
5485         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5486         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5487         uint64_t msg_ref = (uint64_t)msg_var.inner;
5488         if (msg_var.is_owned) {
5489                 msg_ref |= 1;
5490         }
5491         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5492 }
5493 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5494         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5495         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5496         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5497         LDKCommitmentSigned msg_var = *msg;
5498         msg_var = CommitmentSigned_clone(msg);
5499         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5500         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5501         uint64_t msg_ref = (uint64_t)msg_var.inner;
5502         if (msg_var.is_owned) {
5503                 msg_ref |= 1;
5504         }
5505         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5506 }
5507 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5508         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5509         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5510         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5511         LDKRevokeAndACK msg_var = *msg;
5512         msg_var = RevokeAndACK_clone(msg);
5513         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5514         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5515         uint64_t msg_ref = (uint64_t)msg_var.inner;
5516         if (msg_var.is_owned) {
5517                 msg_ref |= 1;
5518         }
5519         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5520 }
5521 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5522         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5523         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5524         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5525         LDKUpdateFee msg_var = *msg;
5526         msg_var = UpdateFee_clone(msg);
5527         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5528         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5529         uint64_t msg_ref = (uint64_t)msg_var.inner;
5530         if (msg_var.is_owned) {
5531                 msg_ref |= 1;
5532         }
5533         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5534 }
5535 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5536         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5537         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5538         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5539         LDKAnnouncementSignatures msg_var = *msg;
5540         msg_var = AnnouncementSignatures_clone(msg);
5541         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5542         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5543         uint64_t msg_ref = (uint64_t)msg_var.inner;
5544         if (msg_var.is_owned) {
5545                 msg_ref |= 1;
5546         }
5547         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5548 }
5549 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5550         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5551         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5552         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5553         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5554 }
5555 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5556         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5557         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5558         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5559         LDKInit msg_var = *msg;
5560         msg_var = Init_clone(msg);
5561         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5562         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5563         uint64_t msg_ref = (uint64_t)msg_var.inner;
5564         if (msg_var.is_owned) {
5565                 msg_ref |= 1;
5566         }
5567         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5568 }
5569 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5570         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5571         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5572         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5573         LDKChannelReestablish msg_var = *msg;
5574         msg_var = ChannelReestablish_clone(msg);
5575         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5576         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5577         uint64_t msg_ref = (uint64_t)msg_var.inner;
5578         if (msg_var.is_owned) {
5579                 msg_ref |= 1;
5580         }
5581         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5582 }
5583 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5584         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5585         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5586         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5587         LDKChannelUpdate msg_var = *msg;
5588         msg_var = ChannelUpdate_clone(msg);
5589         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5590         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5591         uint64_t msg_ref = (uint64_t)msg_var.inner;
5592         if (msg_var.is_owned) {
5593                 msg_ref |= 1;
5594         }
5595         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5596 }
5597 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5598         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5599         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5600         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5601         LDKErrorMessage msg_var = *msg;
5602         msg_var = ErrorMessage_clone(msg);
5603         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5604         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5605         uint64_t msg_ref = (uint64_t)msg_var.inner;
5606         if (msg_var.is_owned) {
5607                 msg_ref |= 1;
5608         }
5609         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5610 }
5611 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5612         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5613         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5614         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5615         return (void*) this_arg;
5616 }
5617 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5618         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5619         atomic_init(&calls->refcnt, 1);
5620         //TODO: Assign calls->o from o
5621
5622         LDKChannelMessageHandler ret = {
5623                 .this_arg = (void*) calls,
5624                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5625                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5626                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5627                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5628                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5629                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5630                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5631                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5632                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5633                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5634                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5635                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5636                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5637                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5638                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5639                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5640                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5641                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5642                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5643                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5644                 .free = LDKChannelMessageHandler_JCalls_free,
5645                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5646         };
5647         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5648         return ret;
5649 }
5650 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5651         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5652         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
5653         return (long)res_ptr;
5654 }
5655 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) {
5656         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5657         LDKPublicKey their_node_id_ref;
5658         CHECK(*((uint32_t*)their_node_id) == 33);
5659         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5660         LDKInitFeatures their_features_conv;
5661         their_features_conv.inner = (void*)(their_features & (~1));
5662         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5663         their_features_conv = InitFeatures_clone(&their_features_conv);
5664         LDKOpenChannel msg_conv;
5665         msg_conv.inner = (void*)(msg & (~1));
5666         msg_conv.is_owned = false;
5667         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5668 }
5669
5670 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) {
5671         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5672         LDKPublicKey their_node_id_ref;
5673         CHECK(*((uint32_t*)their_node_id) == 33);
5674         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5675         LDKInitFeatures their_features_conv;
5676         their_features_conv.inner = (void*)(their_features & (~1));
5677         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5678         their_features_conv = InitFeatures_clone(&their_features_conv);
5679         LDKAcceptChannel msg_conv;
5680         msg_conv.inner = (void*)(msg & (~1));
5681         msg_conv.is_owned = false;
5682         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5683 }
5684
5685 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5686         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5687         LDKPublicKey their_node_id_ref;
5688         CHECK(*((uint32_t*)their_node_id) == 33);
5689         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5690         LDKFundingCreated msg_conv;
5691         msg_conv.inner = (void*)(msg & (~1));
5692         msg_conv.is_owned = false;
5693         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5694 }
5695
5696 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5697         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5698         LDKPublicKey their_node_id_ref;
5699         CHECK(*((uint32_t*)their_node_id) == 33);
5700         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5701         LDKFundingSigned msg_conv;
5702         msg_conv.inner = (void*)(msg & (~1));
5703         msg_conv.is_owned = false;
5704         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5705 }
5706
5707 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5708         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5709         LDKPublicKey their_node_id_ref;
5710         CHECK(*((uint32_t*)their_node_id) == 33);
5711         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5712         LDKFundingLocked msg_conv;
5713         msg_conv.inner = (void*)(msg & (~1));
5714         msg_conv.is_owned = false;
5715         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5716 }
5717
5718 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
5719         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5720         LDKPublicKey their_node_id_ref;
5721         CHECK(*((uint32_t*)their_node_id) == 33);
5722         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5723         LDKInitFeatures their_features_conv;
5724         their_features_conv.inner = (void*)(their_features & (~1));
5725         their_features_conv.is_owned = false;
5726         LDKShutdown msg_conv;
5727         msg_conv.inner = (void*)(msg & (~1));
5728         msg_conv.is_owned = false;
5729         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5730 }
5731
5732 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5733         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5734         LDKPublicKey their_node_id_ref;
5735         CHECK(*((uint32_t*)their_node_id) == 33);
5736         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5737         LDKClosingSigned msg_conv;
5738         msg_conv.inner = (void*)(msg & (~1));
5739         msg_conv.is_owned = false;
5740         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5741 }
5742
5743 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5744         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5745         LDKPublicKey their_node_id_ref;
5746         CHECK(*((uint32_t*)their_node_id) == 33);
5747         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5748         LDKUpdateAddHTLC msg_conv;
5749         msg_conv.inner = (void*)(msg & (~1));
5750         msg_conv.is_owned = false;
5751         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5752 }
5753
5754 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5755         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5756         LDKPublicKey their_node_id_ref;
5757         CHECK(*((uint32_t*)their_node_id) == 33);
5758         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5759         LDKUpdateFulfillHTLC msg_conv;
5760         msg_conv.inner = (void*)(msg & (~1));
5761         msg_conv.is_owned = false;
5762         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5763 }
5764
5765 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5766         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5767         LDKPublicKey their_node_id_ref;
5768         CHECK(*((uint32_t*)their_node_id) == 33);
5769         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5770         LDKUpdateFailHTLC msg_conv;
5771         msg_conv.inner = (void*)(msg & (~1));
5772         msg_conv.is_owned = false;
5773         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5774 }
5775
5776 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5777         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5778         LDKPublicKey their_node_id_ref;
5779         CHECK(*((uint32_t*)their_node_id) == 33);
5780         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5781         LDKUpdateFailMalformedHTLC msg_conv;
5782         msg_conv.inner = (void*)(msg & (~1));
5783         msg_conv.is_owned = false;
5784         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5785 }
5786
5787 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5788         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5789         LDKPublicKey their_node_id_ref;
5790         CHECK(*((uint32_t*)their_node_id) == 33);
5791         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5792         LDKCommitmentSigned msg_conv;
5793         msg_conv.inner = (void*)(msg & (~1));
5794         msg_conv.is_owned = false;
5795         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5796 }
5797
5798 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5799         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5800         LDKPublicKey their_node_id_ref;
5801         CHECK(*((uint32_t*)their_node_id) == 33);
5802         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5803         LDKRevokeAndACK msg_conv;
5804         msg_conv.inner = (void*)(msg & (~1));
5805         msg_conv.is_owned = false;
5806         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5807 }
5808
5809 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5810         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5811         LDKPublicKey their_node_id_ref;
5812         CHECK(*((uint32_t*)their_node_id) == 33);
5813         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5814         LDKUpdateFee msg_conv;
5815         msg_conv.inner = (void*)(msg & (~1));
5816         msg_conv.is_owned = false;
5817         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5818 }
5819
5820 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5821         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5822         LDKPublicKey their_node_id_ref;
5823         CHECK(*((uint32_t*)their_node_id) == 33);
5824         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5825         LDKAnnouncementSignatures msg_conv;
5826         msg_conv.inner = (void*)(msg & (~1));
5827         msg_conv.is_owned = false;
5828         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5829 }
5830
5831 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5832         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5833         LDKPublicKey their_node_id_ref;
5834         CHECK(*((uint32_t*)their_node_id) == 33);
5835         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5836         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5837 }
5838
5839 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5840         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5841         LDKPublicKey their_node_id_ref;
5842         CHECK(*((uint32_t*)their_node_id) == 33);
5843         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5844         LDKInit msg_conv;
5845         msg_conv.inner = (void*)(msg & (~1));
5846         msg_conv.is_owned = false;
5847         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5848 }
5849
5850 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5851         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5852         LDKPublicKey their_node_id_ref;
5853         CHECK(*((uint32_t*)their_node_id) == 33);
5854         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5855         LDKChannelReestablish msg_conv;
5856         msg_conv.inner = (void*)(msg & (~1));
5857         msg_conv.is_owned = false;
5858         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5859 }
5860
5861 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5862         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5863         LDKPublicKey their_node_id_ref;
5864         CHECK(*((uint32_t*)their_node_id) == 33);
5865         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5866         LDKChannelUpdate msg_conv;
5867         msg_conv.inner = (void*)(msg & (~1));
5868         msg_conv.is_owned = false;
5869         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5870 }
5871
5872 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5873         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5874         LDKPublicKey their_node_id_ref;
5875         CHECK(*((uint32_t*)their_node_id) == 33);
5876         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5877         LDKErrorMessage msg_conv;
5878         msg_conv.inner = (void*)(msg & (~1));
5879         msg_conv.is_owned = false;
5880         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5881 }
5882
5883 typedef struct LDKRoutingMessageHandler_JCalls {
5884         atomic_size_t refcnt;
5885         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5886         uint32_t handle_node_announcement_meth;
5887         uint32_t handle_channel_announcement_meth;
5888         uint32_t handle_channel_update_meth;
5889         uint32_t handle_htlc_fail_channel_update_meth;
5890         uint32_t get_next_channel_announcements_meth;
5891         uint32_t get_next_node_announcements_meth;
5892         uint32_t sync_routing_table_meth;
5893         uint32_t handle_reply_channel_range_meth;
5894         uint32_t handle_reply_short_channel_ids_end_meth;
5895         uint32_t handle_query_channel_range_meth;
5896         uint32_t handle_query_short_channel_ids_meth;
5897 } LDKRoutingMessageHandler_JCalls;
5898 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5899         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5900         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5901                 js_free(j_calls->handle_node_announcement_meth);
5902                 js_free(j_calls->handle_channel_announcement_meth);
5903                 js_free(j_calls->handle_channel_update_meth);
5904                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
5905                 js_free(j_calls->get_next_channel_announcements_meth);
5906                 js_free(j_calls->get_next_node_announcements_meth);
5907                 js_free(j_calls->sync_routing_table_meth);
5908                 js_free(j_calls->handle_reply_channel_range_meth);
5909                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
5910                 js_free(j_calls->handle_query_channel_range_meth);
5911                 js_free(j_calls->handle_query_short_channel_ids_meth);
5912                 FREE(j_calls);
5913         }
5914 }
5915 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5916         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5917         LDKNodeAnnouncement msg_var = *msg;
5918         msg_var = NodeAnnouncement_clone(msg);
5919         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5920         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5921         uint64_t msg_ref = (uint64_t)msg_var.inner;
5922         if (msg_var.is_owned) {
5923                 msg_ref |= 1;
5924         }
5925         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5926         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5927         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5928         return ret_conv;
5929 }
5930 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5931         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5932         LDKChannelAnnouncement msg_var = *msg;
5933         msg_var = ChannelAnnouncement_clone(msg);
5934         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5935         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5936         uint64_t msg_ref = (uint64_t)msg_var.inner;
5937         if (msg_var.is_owned) {
5938                 msg_ref |= 1;
5939         }
5940         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5941         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5942         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5943         return ret_conv;
5944 }
5945 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5946         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5947         LDKChannelUpdate msg_var = *msg;
5948         msg_var = ChannelUpdate_clone(msg);
5949         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5950         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5951         uint64_t msg_ref = (uint64_t)msg_var.inner;
5952         if (msg_var.is_owned) {
5953                 msg_ref |= 1;
5954         }
5955         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5956         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5957         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5958         return ret_conv;
5959 }
5960 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5961         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5962         uint64_t ret_update = (uint64_t)update;
5963         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5964 }
5965 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5966         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5967         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5968         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5969         ret_constr.datalen = *((uint32_t*)ret);
5970         if (ret_constr.datalen > 0)
5971                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5972         else
5973                 ret_constr.data = NULL;
5974         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5975         for (size_t l = 0; l < ret_constr.datalen; l++) {
5976                 uint32_t ret_conv_63 = ret_vals[l];
5977                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5978                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5979                 ret_constr.data[l] = ret_conv_63_conv;
5980         }
5981         return ret_constr;
5982 }
5983 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5984         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5985         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5986         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5987         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5988         LDKCVec_NodeAnnouncementZ ret_constr;
5989         ret_constr.datalen = *((uint32_t*)ret);
5990         if (ret_constr.datalen > 0)
5991                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5992         else
5993                 ret_constr.data = NULL;
5994         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5995         for (size_t s = 0; s < ret_constr.datalen; s++) {
5996                 uint32_t ret_conv_18 = ret_vals[s];
5997                 LDKNodeAnnouncement ret_conv_18_conv;
5998                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5999                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6000                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6001                 ret_constr.data[s] = ret_conv_18_conv;
6002         }
6003         return ret_constr;
6004 }
6005 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6006         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6007         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6008         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6009         LDKInit init_var = *init;
6010         init_var = Init_clone(init);
6011         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6012         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6013         uint64_t init_ref = (uint64_t)init_var.inner;
6014         if (init_var.is_owned) {
6015                 init_ref |= 1;
6016         }
6017         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6018 }
6019 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6020         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6021         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6022         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6023         LDKReplyChannelRange msg_var = msg;
6024         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6025         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6026         uint64_t msg_ref = (uint64_t)msg_var.inner;
6027         if (msg_var.is_owned) {
6028                 msg_ref |= 1;
6029         }
6030         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6031         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6032         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6033         return ret_conv;
6034 }
6035 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6036         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6037         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6038         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6039         LDKReplyShortChannelIdsEnd msg_var = msg;
6040         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6041         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6042         uint64_t msg_ref = (uint64_t)msg_var.inner;
6043         if (msg_var.is_owned) {
6044                 msg_ref |= 1;
6045         }
6046         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6047         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6048         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6049         return ret_conv;
6050 }
6051 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6052         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6053         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6054         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6055         LDKQueryChannelRange msg_var = msg;
6056         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6057         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6058         uint64_t msg_ref = (uint64_t)msg_var.inner;
6059         if (msg_var.is_owned) {
6060                 msg_ref |= 1;
6061         }
6062         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6063         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6064         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6065         return ret_conv;
6066 }
6067 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6068         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6069         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6070         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6071         LDKQueryShortChannelIds msg_var = msg;
6072         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6073         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6074         uint64_t msg_ref = (uint64_t)msg_var.inner;
6075         if (msg_var.is_owned) {
6076                 msg_ref |= 1;
6077         }
6078         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6079         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6080         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6081         return ret_conv;
6082 }
6083 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6084         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6085         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6086         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6087         return (void*) this_arg;
6088 }
6089 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6090         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6091         atomic_init(&calls->refcnt, 1);
6092         //TODO: Assign calls->o from o
6093
6094         LDKRoutingMessageHandler ret = {
6095                 .this_arg = (void*) calls,
6096                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6097                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6098                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6099                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6100                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6101                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6102                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6103                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6104                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6105                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6106                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6107                 .free = LDKRoutingMessageHandler_JCalls_free,
6108                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6109         };
6110         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6111         return ret;
6112 }
6113 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6114         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6115         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6116         return (long)res_ptr;
6117 }
6118 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6119         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6120         LDKNodeAnnouncement msg_conv;
6121         msg_conv.inner = (void*)(msg & (~1));
6122         msg_conv.is_owned = false;
6123         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6124         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6125         return (uint64_t)ret_conv;
6126 }
6127
6128 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6129         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6130         LDKChannelAnnouncement msg_conv;
6131         msg_conv.inner = (void*)(msg & (~1));
6132         msg_conv.is_owned = false;
6133         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6134         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6135         return (uint64_t)ret_conv;
6136 }
6137
6138 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6139         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6140         LDKChannelUpdate msg_conv;
6141         msg_conv.inner = (void*)(msg & (~1));
6142         msg_conv.is_owned = false;
6143         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6144         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6145         return (uint64_t)ret_conv;
6146 }
6147
6148 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
6149         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6150         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6151         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6152 }
6153
6154 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6155         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6156         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6157         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6158         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6159         for (size_t l = 0; l < ret_var.datalen; l++) {
6160                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6161                 *ret_conv_63_ref = ret_var.data[l];
6162                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6163         }
6164         FREE(ret_var.data);
6165         return ret_arr;
6166 }
6167
6168 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6169         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6170         LDKPublicKey starting_point_ref;
6171         CHECK(*((uint32_t*)starting_point) == 33);
6172         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6173         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6174         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6175         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6176         for (size_t s = 0; s < ret_var.datalen; s++) {
6177                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6178                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6179                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6180                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6181                 if (ret_conv_18_var.is_owned) {
6182                         ret_conv_18_ref |= 1;
6183                 }
6184                 ret_arr_ptr[s] = ret_conv_18_ref;
6185         }
6186         FREE(ret_var.data);
6187         return ret_arr;
6188 }
6189
6190 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6191         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6192         LDKPublicKey their_node_id_ref;
6193         CHECK(*((uint32_t*)their_node_id) == 33);
6194         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6195         LDKInit init_conv;
6196         init_conv.inner = (void*)(init & (~1));
6197         init_conv.is_owned = false;
6198         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6199 }
6200
6201 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6202         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6203         LDKPublicKey their_node_id_ref;
6204         CHECK(*((uint32_t*)their_node_id) == 33);
6205         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6206         LDKReplyChannelRange msg_conv;
6207         msg_conv.inner = (void*)(msg & (~1));
6208         msg_conv.is_owned = (msg & 1) || (msg == 0);
6209         msg_conv = ReplyChannelRange_clone(&msg_conv);
6210         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6211         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6212         return (uint64_t)ret_conv;
6213 }
6214
6215 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) {
6216         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6217         LDKPublicKey their_node_id_ref;
6218         CHECK(*((uint32_t*)their_node_id) == 33);
6219         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6220         LDKReplyShortChannelIdsEnd msg_conv;
6221         msg_conv.inner = (void*)(msg & (~1));
6222         msg_conv.is_owned = (msg & 1) || (msg == 0);
6223         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6224         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6225         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6226         return (uint64_t)ret_conv;
6227 }
6228
6229 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6230         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6231         LDKPublicKey their_node_id_ref;
6232         CHECK(*((uint32_t*)their_node_id) == 33);
6233         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6234         LDKQueryChannelRange msg_conv;
6235         msg_conv.inner = (void*)(msg & (~1));
6236         msg_conv.is_owned = (msg & 1) || (msg == 0);
6237         msg_conv = QueryChannelRange_clone(&msg_conv);
6238         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6239         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6240         return (uint64_t)ret_conv;
6241 }
6242
6243 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6244         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6245         LDKPublicKey their_node_id_ref;
6246         CHECK(*((uint32_t*)their_node_id) == 33);
6247         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6248         LDKQueryShortChannelIds msg_conv;
6249         msg_conv.inner = (void*)(msg & (~1));
6250         msg_conv.is_owned = (msg & 1) || (msg == 0);
6251         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6252         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6253         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6254         return (uint64_t)ret_conv;
6255 }
6256
6257 typedef struct LDKSocketDescriptor_JCalls {
6258         atomic_size_t refcnt;
6259         uint32_t send_data_meth;
6260         uint32_t disconnect_socket_meth;
6261         uint32_t eq_meth;
6262         uint32_t hash_meth;
6263 } LDKSocketDescriptor_JCalls;
6264 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6265         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6266         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6267                 js_free(j_calls->send_data_meth);
6268                 js_free(j_calls->disconnect_socket_meth);
6269                 js_free(j_calls->eq_meth);
6270                 js_free(j_calls->hash_meth);
6271                 FREE(j_calls);
6272         }
6273 }
6274 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6275         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6276         LDKu8slice data_var = data;
6277         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6278         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6279         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6280 }
6281 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6282         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6283         js_invoke_function_0(j_calls->disconnect_socket_meth);
6284 }
6285 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6286         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6287         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6288         *other_arg_clone = SocketDescriptor_clone(other_arg);
6289         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6290 }
6291 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6292         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6293         return js_invoke_function_0(j_calls->hash_meth);
6294 }
6295 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6296         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6297         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6298         return (void*) this_arg;
6299 }
6300 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6301         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6302         atomic_init(&calls->refcnt, 1);
6303         //TODO: Assign calls->o from o
6304
6305         LDKSocketDescriptor ret = {
6306                 .this_arg = (void*) calls,
6307                 .send_data = send_data_LDKSocketDescriptor_jcall,
6308                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6309                 .eq = eq_LDKSocketDescriptor_jcall,
6310                 .hash = hash_LDKSocketDescriptor_jcall,
6311                 .clone = LDKSocketDescriptor_JCalls_clone,
6312                 .free = LDKSocketDescriptor_JCalls_free,
6313         };
6314         return ret;
6315 }
6316 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6317         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6318         *res_ptr = LDKSocketDescriptor_init(o);
6319         return (long)res_ptr;
6320 }
6321 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6322         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6323         LDKu8slice data_ref;
6324         data_ref.datalen = *((uint32_t*)data);
6325         data_ref.data = (int8_t*)(data + 4);
6326         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6327         return ret_val;
6328 }
6329
6330 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6331         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6332         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6333 }
6334
6335 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6336         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6337         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6338         return ret_val;
6339 }
6340
6341 typedef struct LDKChannelManagerPersister_JCalls {
6342         atomic_size_t refcnt;
6343         uint32_t persist_manager_meth;
6344 } LDKChannelManagerPersister_JCalls;
6345 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6346         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6347         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6348                 js_free(j_calls->persist_manager_meth);
6349                 FREE(j_calls);
6350         }
6351 }
6352 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6353         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6354         LDKChannelManager channel_manager_var = *channel_manager;
6355         // Warning: we may need a move here but no clone is available for LDKChannelManager
6356         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6357         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6358         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6359         if (channel_manager_var.is_owned) {
6360                 channel_manager_ref |= 1;
6361         }
6362         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6363         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6364         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6365         return ret_conv;
6366 }
6367 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
6368         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6369         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6370         return (void*) this_arg;
6371 }
6372 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6373         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6374         atomic_init(&calls->refcnt, 1);
6375         //TODO: Assign calls->o from o
6376
6377         LDKChannelManagerPersister ret = {
6378                 .this_arg = (void*) calls,
6379                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6380                 .free = LDKChannelManagerPersister_JCalls_free,
6381         };
6382         return ret;
6383 }
6384 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6385         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6386         *res_ptr = LDKChannelManagerPersister_init(o);
6387         return (long)res_ptr;
6388 }
6389 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
6390         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
6391         LDKChannelManager channel_manager_conv;
6392         channel_manager_conv.inner = (void*)(channel_manager & (~1));
6393         channel_manager_conv.is_owned = false;
6394         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6395         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
6396         return (uint64_t)ret_conv;
6397 }
6398
6399 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
6400         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
6401         switch(obj->tag) {
6402                 case LDKFallback_SegWitProgram: {
6403                         uint8_t version_val = obj->seg_wit_program.version._0;
6404                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
6405                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6406                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
6407                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
6408                 }
6409                 case LDKFallback_PubKeyHash: {
6410                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6411                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
6412                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
6413                 }
6414                 case LDKFallback_ScriptHash: {
6415                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6416                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
6417                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
6418                 }
6419                 default: abort();
6420         }
6421 }
6422 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
6423         LDKStr ret_str = _ldk_get_compiled_version();
6424         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6425         return ret_conv;
6426 }
6427
6428 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
6429         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
6430         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6431         return ret_conv;
6432 }
6433
6434 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
6435         LDKTransaction _res_ref;
6436         _res_ref.datalen = *((uint32_t*)_res);
6437         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6438         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6439         _res_ref.data_is_owned = true;
6440         Transaction_free(_res_ref);
6441 }
6442
6443 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
6444         if ((_res & 1) != 0) return;
6445         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6446         FREE((void*)_res);
6447         TxOut_free(_res_conv);
6448 }
6449
6450 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
6451         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6452         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6453         *ret_ref = TxOut_clone(orig_conv);
6454         return (uint64_t)ret_ref;
6455 }
6456
6457 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
6458         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
6459         Str_free(dummy);
6460 }
6461
6462 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
6463         LDKSecretKey o_ref;
6464         CHECK(*((uint32_t*)o) == 32);
6465         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
6466         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6467         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6468         return (uint64_t)ret_conv;
6469 }
6470
6471 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
6472         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6473         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6474         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6475         return (uint64_t)ret_conv;
6476 }
6477
6478 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
6479         if ((_res & 1) != 0) return;
6480         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6481         FREE((void*)_res);
6482         CResult_SecretKeyErrorZ_free(_res_conv);
6483 }
6484
6485 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
6486         LDKPublicKey o_ref;
6487         CHECK(*((uint32_t*)o) == 33);
6488         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6489         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6490         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6491         return (uint64_t)ret_conv;
6492 }
6493
6494 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
6495         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6496         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6497         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6498         return (uint64_t)ret_conv;
6499 }
6500
6501 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
6502         if ((_res & 1) != 0) return;
6503         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6504         FREE((void*)_res);
6505         CResult_PublicKeyErrorZ_free(_res_conv);
6506 }
6507
6508 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
6509         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
6510         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6511         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
6512         return (uint64_t)ret_conv;
6513 }
6514
6515 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
6516         LDKTxCreationKeys o_conv;
6517         o_conv.inner = (void*)(o & (~1));
6518         o_conv.is_owned = (o & 1) || (o == 0);
6519         o_conv = TxCreationKeys_clone(&o_conv);
6520         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6521         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6522         return (uint64_t)ret_conv;
6523 }
6524
6525 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
6526         LDKDecodeError e_conv;
6527         e_conv.inner = (void*)(e & (~1));
6528         e_conv.is_owned = (e & 1) || (e == 0);
6529         e_conv = DecodeError_clone(&e_conv);
6530         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6531         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6532         return (uint64_t)ret_conv;
6533 }
6534
6535 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
6536         if ((_res & 1) != 0) return;
6537         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6538         FREE((void*)_res);
6539         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6540 }
6541
6542 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
6543         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6544         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6545         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6546         return (uint64_t)ret_conv;
6547 }
6548
6549 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
6550         LDKChannelPublicKeys o_conv;
6551         o_conv.inner = (void*)(o & (~1));
6552         o_conv.is_owned = (o & 1) || (o == 0);
6553         o_conv = ChannelPublicKeys_clone(&o_conv);
6554         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6555         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6556         return (uint64_t)ret_conv;
6557 }
6558
6559 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
6560         LDKDecodeError e_conv;
6561         e_conv.inner = (void*)(e & (~1));
6562         e_conv.is_owned = (e & 1) || (e == 0);
6563         e_conv = DecodeError_clone(&e_conv);
6564         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6565         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6566         return (uint64_t)ret_conv;
6567 }
6568
6569 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
6570         if ((_res & 1) != 0) return;
6571         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6572         FREE((void*)_res);
6573         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6574 }
6575
6576 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
6577         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6578         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6579         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6580         return (uint64_t)ret_conv;
6581 }
6582
6583 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
6584         LDKTxCreationKeys o_conv;
6585         o_conv.inner = (void*)(o & (~1));
6586         o_conv.is_owned = (o & 1) || (o == 0);
6587         o_conv = TxCreationKeys_clone(&o_conv);
6588         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6589         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6590         return (uint64_t)ret_conv;
6591 }
6592
6593 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
6594         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6595         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6596         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6597         return (uint64_t)ret_conv;
6598 }
6599
6600 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
6601         if ((_res & 1) != 0) return;
6602         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6603         FREE((void*)_res);
6604         CResult_TxCreationKeysErrorZ_free(_res_conv);
6605 }
6606
6607 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
6608         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
6609         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6610         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
6611         return (uint64_t)ret_conv;
6612 }
6613
6614 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
6615         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6616         *ret_copy = COption_u32Z_some(o);
6617         uint64_t ret_ref = (uint64_t)ret_copy;
6618         return ret_ref;
6619 }
6620
6621 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
6622         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6623         *ret_copy = COption_u32Z_none();
6624         uint64_t ret_ref = (uint64_t)ret_copy;
6625         return ret_ref;
6626 }
6627
6628 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
6629         if ((_res & 1) != 0) return;
6630         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6631         FREE((void*)_res);
6632         COption_u32Z_free(_res_conv);
6633 }
6634
6635 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
6636         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6637         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6638         *ret_copy = COption_u32Z_clone(orig_conv);
6639         uint64_t ret_ref = (uint64_t)ret_copy;
6640         return ret_ref;
6641 }
6642
6643 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
6644         LDKHTLCOutputInCommitment o_conv;
6645         o_conv.inner = (void*)(o & (~1));
6646         o_conv.is_owned = (o & 1) || (o == 0);
6647         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6648         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6649         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6650         return (uint64_t)ret_conv;
6651 }
6652
6653 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
6654         LDKDecodeError e_conv;
6655         e_conv.inner = (void*)(e & (~1));
6656         e_conv.is_owned = (e & 1) || (e == 0);
6657         e_conv = DecodeError_clone(&e_conv);
6658         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6659         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6660         return (uint64_t)ret_conv;
6661 }
6662
6663 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
6664         if ((_res & 1) != 0) return;
6665         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6666         FREE((void*)_res);
6667         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6668 }
6669
6670 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
6671         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6672         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6673         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6674         return (uint64_t)ret_conv;
6675 }
6676
6677 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6678         LDKCounterpartyChannelTransactionParameters o_conv;
6679         o_conv.inner = (void*)(o & (~1));
6680         o_conv.is_owned = (o & 1) || (o == 0);
6681         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6682         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6683         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6684         return (uint64_t)ret_conv;
6685 }
6686
6687 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6688         LDKDecodeError e_conv;
6689         e_conv.inner = (void*)(e & (~1));
6690         e_conv.is_owned = (e & 1) || (e == 0);
6691         e_conv = DecodeError_clone(&e_conv);
6692         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6693         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6694         return (uint64_t)ret_conv;
6695 }
6696
6697 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6698         if ((_res & 1) != 0) return;
6699         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6700         FREE((void*)_res);
6701         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6702 }
6703
6704 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6705         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6706         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6707         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6708         return (uint64_t)ret_conv;
6709 }
6710
6711 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6712         LDKChannelTransactionParameters o_conv;
6713         o_conv.inner = (void*)(o & (~1));
6714         o_conv.is_owned = (o & 1) || (o == 0);
6715         o_conv = ChannelTransactionParameters_clone(&o_conv);
6716         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6717         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6718         return (uint64_t)ret_conv;
6719 }
6720
6721 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6722         LDKDecodeError e_conv;
6723         e_conv.inner = (void*)(e & (~1));
6724         e_conv.is_owned = (e & 1) || (e == 0);
6725         e_conv = DecodeError_clone(&e_conv);
6726         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6727         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6728         return (uint64_t)ret_conv;
6729 }
6730
6731 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6732         if ((_res & 1) != 0) return;
6733         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6734         FREE((void*)_res);
6735         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6736 }
6737
6738 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6739         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6740         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6741         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6742         return (uint64_t)ret_conv;
6743 }
6744
6745 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
6746         LDKCVec_SignatureZ _res_constr;
6747         _res_constr.datalen = *((uint32_t*)_res);
6748         if (_res_constr.datalen > 0)
6749                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6750         else
6751                 _res_constr.data = NULL;
6752         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6753         for (size_t m = 0; m < _res_constr.datalen; m++) {
6754                 int8_tArray _res_conv_12 = _res_vals[m];
6755                 LDKSignature _res_conv_12_ref;
6756                 CHECK(*((uint32_t*)_res_conv_12) == 64);
6757                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
6758                 _res_constr.data[m] = _res_conv_12_ref;
6759         }
6760         CVec_SignatureZ_free(_res_constr);
6761 }
6762
6763 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6764         LDKHolderCommitmentTransaction o_conv;
6765         o_conv.inner = (void*)(o & (~1));
6766         o_conv.is_owned = (o & 1) || (o == 0);
6767         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6768         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6769         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6770         return (uint64_t)ret_conv;
6771 }
6772
6773 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6774         LDKDecodeError e_conv;
6775         e_conv.inner = (void*)(e & (~1));
6776         e_conv.is_owned = (e & 1) || (e == 0);
6777         e_conv = DecodeError_clone(&e_conv);
6778         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6779         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6780         return (uint64_t)ret_conv;
6781 }
6782
6783 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6784         if ((_res & 1) != 0) return;
6785         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6786         FREE((void*)_res);
6787         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6788 }
6789
6790 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6791         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6792         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6793         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6794         return (uint64_t)ret_conv;
6795 }
6796
6797 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6798         LDKBuiltCommitmentTransaction o_conv;
6799         o_conv.inner = (void*)(o & (~1));
6800         o_conv.is_owned = (o & 1) || (o == 0);
6801         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6802         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6803         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6804         return (uint64_t)ret_conv;
6805 }
6806
6807 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6808         LDKDecodeError e_conv;
6809         e_conv.inner = (void*)(e & (~1));
6810         e_conv.is_owned = (e & 1) || (e == 0);
6811         e_conv = DecodeError_clone(&e_conv);
6812         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6813         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6814         return (uint64_t)ret_conv;
6815 }
6816
6817 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6818         if ((_res & 1) != 0) return;
6819         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6820         FREE((void*)_res);
6821         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6822 }
6823
6824 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6825         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6826         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6827         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6828         return (uint64_t)ret_conv;
6829 }
6830
6831 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6832         LDKCommitmentTransaction o_conv;
6833         o_conv.inner = (void*)(o & (~1));
6834         o_conv.is_owned = (o & 1) || (o == 0);
6835         o_conv = CommitmentTransaction_clone(&o_conv);
6836         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6837         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6838         return (uint64_t)ret_conv;
6839 }
6840
6841 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6842         LDKDecodeError e_conv;
6843         e_conv.inner = (void*)(e & (~1));
6844         e_conv.is_owned = (e & 1) || (e == 0);
6845         e_conv = DecodeError_clone(&e_conv);
6846         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6847         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6848         return (uint64_t)ret_conv;
6849 }
6850
6851 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6852         if ((_res & 1) != 0) return;
6853         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6854         FREE((void*)_res);
6855         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6856 }
6857
6858 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6859         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6860         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6861         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6862         return (uint64_t)ret_conv;
6863 }
6864
6865 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6866         LDKTrustedCommitmentTransaction o_conv;
6867         o_conv.inner = (void*)(o & (~1));
6868         o_conv.is_owned = (o & 1) || (o == 0);
6869         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6870         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6871         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6872         return (uint64_t)ret_conv;
6873 }
6874
6875 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6876         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6877         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6878         return (uint64_t)ret_conv;
6879 }
6880
6881 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6882         if ((_res & 1) != 0) return;
6883         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6884         FREE((void*)_res);
6885         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6886 }
6887
6888 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
6889         LDKCVec_SignatureZ o_constr;
6890         o_constr.datalen = *((uint32_t*)o);
6891         if (o_constr.datalen > 0)
6892                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6893         else
6894                 o_constr.data = NULL;
6895         int8_tArray* o_vals = (int8_tArray*)(o + 4);
6896         for (size_t m = 0; m < o_constr.datalen; m++) {
6897                 int8_tArray o_conv_12 = o_vals[m];
6898                 LDKSignature o_conv_12_ref;
6899                 CHECK(*((uint32_t*)o_conv_12) == 64);
6900                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
6901                 o_constr.data[m] = o_conv_12_ref;
6902         }
6903         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6904         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6905         return (uint64_t)ret_conv;
6906 }
6907
6908 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
6909         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6910         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6911         return (uint64_t)ret_conv;
6912 }
6913
6914 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
6915         if ((_res & 1) != 0) return;
6916         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6917         FREE((void*)_res);
6918         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6919 }
6920
6921 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
6922         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6923         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6924         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6925         return (uint64_t)ret_conv;
6926 }
6927
6928 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
6929         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6930         *ret_conv = CResult_NoneErrorZ_ok();
6931         return (uint64_t)ret_conv;
6932 }
6933
6934 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
6935         LDKIOError e_conv = LDKIOError_from_js(e);
6936         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6937         *ret_conv = CResult_NoneErrorZ_err(e_conv);
6938         return (uint64_t)ret_conv;
6939 }
6940
6941 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
6942         if ((_res & 1) != 0) return;
6943         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
6944         FREE((void*)_res);
6945         CResult_NoneErrorZ_free(_res_conv);
6946 }
6947
6948 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
6949         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
6950         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6951         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
6952         return (uint64_t)ret_conv;
6953 }
6954
6955 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
6956         LDKRouteHop o_conv;
6957         o_conv.inner = (void*)(o & (~1));
6958         o_conv.is_owned = (o & 1) || (o == 0);
6959         o_conv = RouteHop_clone(&o_conv);
6960         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6961         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
6962         return (uint64_t)ret_conv;
6963 }
6964
6965 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
6966         LDKDecodeError e_conv;
6967         e_conv.inner = (void*)(e & (~1));
6968         e_conv.is_owned = (e & 1) || (e == 0);
6969         e_conv = DecodeError_clone(&e_conv);
6970         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6971         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
6972         return (uint64_t)ret_conv;
6973 }
6974
6975 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
6976         if ((_res & 1) != 0) return;
6977         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
6978         FREE((void*)_res);
6979         CResult_RouteHopDecodeErrorZ_free(_res_conv);
6980 }
6981
6982 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
6983         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
6984         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6985         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
6986         return (uint64_t)ret_conv;
6987 }
6988
6989 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6990         LDKCVec_RouteHopZ _res_constr;
6991         _res_constr.datalen = *((uint32_t*)_res);
6992         if (_res_constr.datalen > 0)
6993                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6994         else
6995                 _res_constr.data = NULL;
6996         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6997         for (size_t k = 0; k < _res_constr.datalen; k++) {
6998                 uint32_t _res_conv_10 = _res_vals[k];
6999                 LDKRouteHop _res_conv_10_conv;
7000                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7001                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7002                 _res_constr.data[k] = _res_conv_10_conv;
7003         }
7004         CVec_RouteHopZ_free(_res_constr);
7005 }
7006
7007 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7008         LDKCVec_CVec_RouteHopZZ _res_constr;
7009         _res_constr.datalen = *((uint32_t*)_res);
7010         if (_res_constr.datalen > 0)
7011                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7012         else
7013                 _res_constr.data = NULL;
7014         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7015         for (size_t m = 0; m < _res_constr.datalen; m++) {
7016                 uint32_tArray _res_conv_12 = _res_vals[m];
7017                 LDKCVec_RouteHopZ _res_conv_12_constr;
7018                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7019                 if (_res_conv_12_constr.datalen > 0)
7020                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7021                 else
7022                         _res_conv_12_constr.data = NULL;
7023                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7024                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7025                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7026                         LDKRouteHop _res_conv_12_conv_10_conv;
7027                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7028                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7029                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7030                 }
7031                 _res_constr.data[m] = _res_conv_12_constr;
7032         }
7033         CVec_CVec_RouteHopZZ_free(_res_constr);
7034 }
7035
7036 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7037         LDKRoute o_conv;
7038         o_conv.inner = (void*)(o & (~1));
7039         o_conv.is_owned = (o & 1) || (o == 0);
7040         o_conv = Route_clone(&o_conv);
7041         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7042         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7043         return (uint64_t)ret_conv;
7044 }
7045
7046 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7047         LDKDecodeError e_conv;
7048         e_conv.inner = (void*)(e & (~1));
7049         e_conv.is_owned = (e & 1) || (e == 0);
7050         e_conv = DecodeError_clone(&e_conv);
7051         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7052         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7053         return (uint64_t)ret_conv;
7054 }
7055
7056 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7057         if ((_res & 1) != 0) return;
7058         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7059         FREE((void*)_res);
7060         CResult_RouteDecodeErrorZ_free(_res_conv);
7061 }
7062
7063 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7064         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7065         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7066         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7067         return (uint64_t)ret_conv;
7068 }
7069
7070 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7071         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7072         *ret_copy = COption_u64Z_some(o);
7073         uint64_t ret_ref = (uint64_t)ret_copy;
7074         return ret_ref;
7075 }
7076
7077 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7078         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7079         *ret_copy = COption_u64Z_none();
7080         uint64_t ret_ref = (uint64_t)ret_copy;
7081         return ret_ref;
7082 }
7083
7084 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7085         if ((_res & 1) != 0) return;
7086         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7087         FREE((void*)_res);
7088         COption_u64Z_free(_res_conv);
7089 }
7090
7091 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7092         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7093         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7094         *ret_copy = COption_u64Z_clone(orig_conv);
7095         uint64_t ret_ref = (uint64_t)ret_copy;
7096         return ret_ref;
7097 }
7098
7099 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7100         LDKCVec_ChannelDetailsZ _res_constr;
7101         _res_constr.datalen = *((uint32_t*)_res);
7102         if (_res_constr.datalen > 0)
7103                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7104         else
7105                 _res_constr.data = NULL;
7106         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7107         for (size_t q = 0; q < _res_constr.datalen; q++) {
7108                 uint32_t _res_conv_16 = _res_vals[q];
7109                 LDKChannelDetails _res_conv_16_conv;
7110                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7111                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7112                 _res_constr.data[q] = _res_conv_16_conv;
7113         }
7114         CVec_ChannelDetailsZ_free(_res_constr);
7115 }
7116
7117 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7118         LDKCVec_RouteHintZ _res_constr;
7119         _res_constr.datalen = *((uint32_t*)_res);
7120         if (_res_constr.datalen > 0)
7121                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7122         else
7123                 _res_constr.data = NULL;
7124         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7125         for (size_t l = 0; l < _res_constr.datalen; l++) {
7126                 uint32_t _res_conv_11 = _res_vals[l];
7127                 LDKRouteHint _res_conv_11_conv;
7128                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7129                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7130                 _res_constr.data[l] = _res_conv_11_conv;
7131         }
7132         CVec_RouteHintZ_free(_res_constr);
7133 }
7134
7135 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7136         LDKRoute o_conv;
7137         o_conv.inner = (void*)(o & (~1));
7138         o_conv.is_owned = (o & 1) || (o == 0);
7139         o_conv = Route_clone(&o_conv);
7140         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7141         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7142         return (uint64_t)ret_conv;
7143 }
7144
7145 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7146         LDKLightningError e_conv;
7147         e_conv.inner = (void*)(e & (~1));
7148         e_conv.is_owned = (e & 1) || (e == 0);
7149         e_conv = LightningError_clone(&e_conv);
7150         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7151         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7152         return (uint64_t)ret_conv;
7153 }
7154
7155 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7156         if ((_res & 1) != 0) return;
7157         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7158         FREE((void*)_res);
7159         CResult_RouteLightningErrorZ_free(_res_conv);
7160 }
7161
7162 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7163         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7164         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7165         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7166         return (uint64_t)ret_conv;
7167 }
7168
7169 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7170         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7171         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7172         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7173         return (uint64_t)ret_conv;
7174 }
7175
7176 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7177         LDKAccessError e_conv = LDKAccessError_from_js(e);
7178         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7179         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7180         return (uint64_t)ret_conv;
7181 }
7182
7183 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7184         if ((_res & 1) != 0) return;
7185         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7186         FREE((void*)_res);
7187         CResult_TxOutAccessErrorZ_free(_res_conv);
7188 }
7189
7190 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7191         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7192         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7193         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7194         return (uint64_t)ret_conv;
7195 }
7196
7197 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7198         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7199         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7200         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7201         return (uint64_t)ret_ref;
7202 }
7203
7204 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7205         LDKTransaction b_ref;
7206         b_ref.datalen = *((uint32_t*)b);
7207         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7208         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7209         b_ref.data_is_owned = true;
7210         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7211         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7212         return (uint64_t)ret_ref;
7213 }
7214
7215 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7216         if ((_res & 1) != 0) return;
7217         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7218         FREE((void*)_res);
7219         C2Tuple_usizeTransactionZ_free(_res_conv);
7220 }
7221
7222 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7223         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7224         _res_constr.datalen = *((uint32_t*)_res);
7225         if (_res_constr.datalen > 0)
7226                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7227         else
7228                 _res_constr.data = NULL;
7229         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7230         for (size_t e = 0; e < _res_constr.datalen; e++) {
7231                 uint32_t _res_conv_30 = _res_vals[e];
7232                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7233                 FREE((void*)_res_conv_30);
7234                 _res_constr.data[e] = _res_conv_30_conv;
7235         }
7236         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7237 }
7238
7239 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7240         LDKCVec_TxidZ _res_constr;
7241         _res_constr.datalen = *((uint32_t*)_res);
7242         if (_res_constr.datalen > 0)
7243                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7244         else
7245                 _res_constr.data = NULL;
7246         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7247         for (size_t m = 0; m < _res_constr.datalen; m++) {
7248                 int8_tArray _res_conv_12 = _res_vals[m];
7249                 LDKThirtyTwoBytes _res_conv_12_ref;
7250                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7251                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7252                 _res_constr.data[m] = _res_conv_12_ref;
7253         }
7254         CVec_TxidZ_free(_res_constr);
7255 }
7256
7257 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7258         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7259         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7260         return (uint64_t)ret_conv;
7261 }
7262
7263 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7264         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7265         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7266         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7267         return (uint64_t)ret_conv;
7268 }
7269
7270 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7271         if ((_res & 1) != 0) return;
7272         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7273         FREE((void*)_res);
7274         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7275 }
7276
7277 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7278         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7279         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7280         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7281         return (uint64_t)ret_conv;
7282 }
7283
7284 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7285         LDKCVec_MonitorEventZ _res_constr;
7286         _res_constr.datalen = *((uint32_t*)_res);
7287         if (_res_constr.datalen > 0)
7288                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7289         else
7290                 _res_constr.data = NULL;
7291         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7292         for (size_t o = 0; o < _res_constr.datalen; o++) {
7293                 uint32_t _res_conv_14 = _res_vals[o];
7294                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7295                 FREE((void*)_res_conv_14);
7296                 _res_constr.data[o] = _res_conv_14_conv;
7297         }
7298         CVec_MonitorEventZ_free(_res_constr);
7299 }
7300
7301 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7302         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7303         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7304         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7305         uint64_t ret_ref = (uint64_t)ret_copy;
7306         return ret_ref;
7307 }
7308
7309 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7310         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7311         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7312         uint64_t ret_ref = (uint64_t)ret_copy;
7313         return ret_ref;
7314 }
7315
7316 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7317         if ((_res & 1) != 0) return;
7318         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7319         FREE((void*)_res);
7320         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7321 }
7322
7323 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
7324         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
7325         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7326         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
7327         uint64_t ret_ref = (uint64_t)ret_copy;
7328         return ret_ref;
7329 }
7330
7331 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7332         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7333         _res_constr.datalen = *((uint32_t*)_res);
7334         if (_res_constr.datalen > 0)
7335                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7336         else
7337                 _res_constr.data = NULL;
7338         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7339         for (size_t b = 0; b < _res_constr.datalen; b++) {
7340                 uint32_t _res_conv_27 = _res_vals[b];
7341                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7342                 FREE((void*)_res_conv_27);
7343                 _res_constr.data[b] = _res_conv_27_conv;
7344         }
7345         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7346 }
7347
7348 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
7349         LDKCVec_MessageSendEventZ _res_constr;
7350         _res_constr.datalen = *((uint32_t*)_res);
7351         if (_res_constr.datalen > 0)
7352                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7353         else
7354                 _res_constr.data = NULL;
7355         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7356         for (size_t s = 0; s < _res_constr.datalen; s++) {
7357                 uint32_t _res_conv_18 = _res_vals[s];
7358                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7359                 FREE((void*)_res_conv_18);
7360                 _res_constr.data[s] = _res_conv_18_conv;
7361         }
7362         CVec_MessageSendEventZ_free(_res_constr);
7363 }
7364
7365 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7366         LDKInitFeatures o_conv;
7367         o_conv.inner = (void*)(o & (~1));
7368         o_conv.is_owned = (o & 1) || (o == 0);
7369         o_conv = InitFeatures_clone(&o_conv);
7370         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7371         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7372         return (uint64_t)ret_conv;
7373 }
7374
7375 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7376         LDKDecodeError e_conv;
7377         e_conv.inner = (void*)(e & (~1));
7378         e_conv.is_owned = (e & 1) || (e == 0);
7379         e_conv = DecodeError_clone(&e_conv);
7380         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7381         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7382         return (uint64_t)ret_conv;
7383 }
7384
7385 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7386         if ((_res & 1) != 0) return;
7387         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7388         FREE((void*)_res);
7389         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7390 }
7391
7392 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7393         LDKNodeFeatures o_conv;
7394         o_conv.inner = (void*)(o & (~1));
7395         o_conv.is_owned = (o & 1) || (o == 0);
7396         o_conv = NodeFeatures_clone(&o_conv);
7397         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7398         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7399         return (uint64_t)ret_conv;
7400 }
7401
7402 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7403         LDKDecodeError e_conv;
7404         e_conv.inner = (void*)(e & (~1));
7405         e_conv.is_owned = (e & 1) || (e == 0);
7406         e_conv = DecodeError_clone(&e_conv);
7407         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7408         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7409         return (uint64_t)ret_conv;
7410 }
7411
7412 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7413         if ((_res & 1) != 0) return;
7414         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7415         FREE((void*)_res);
7416         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7417 }
7418
7419 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7420         LDKChannelFeatures o_conv;
7421         o_conv.inner = (void*)(o & (~1));
7422         o_conv.is_owned = (o & 1) || (o == 0);
7423         o_conv = ChannelFeatures_clone(&o_conv);
7424         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7425         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7426         return (uint64_t)ret_conv;
7427 }
7428
7429 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7430         LDKDecodeError e_conv;
7431         e_conv.inner = (void*)(e & (~1));
7432         e_conv.is_owned = (e & 1) || (e == 0);
7433         e_conv = DecodeError_clone(&e_conv);
7434         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7435         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7436         return (uint64_t)ret_conv;
7437 }
7438
7439 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7440         if ((_res & 1) != 0) return;
7441         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7442         FREE((void*)_res);
7443         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7444 }
7445
7446 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7447         LDKInvoiceFeatures o_conv;
7448         o_conv.inner = (void*)(o & (~1));
7449         o_conv.is_owned = (o & 1) || (o == 0);
7450         o_conv = InvoiceFeatures_clone(&o_conv);
7451         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7452         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7453         return (uint64_t)ret_conv;
7454 }
7455
7456 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7457         LDKDecodeError e_conv;
7458         e_conv.inner = (void*)(e & (~1));
7459         e_conv.is_owned = (e & 1) || (e == 0);
7460         e_conv = DecodeError_clone(&e_conv);
7461         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7462         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7463         return (uint64_t)ret_conv;
7464 }
7465
7466 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7467         if ((_res & 1) != 0) return;
7468         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7469         FREE((void*)_res);
7470         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7471 }
7472
7473 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7474         LDKDelayedPaymentOutputDescriptor o_conv;
7475         o_conv.inner = (void*)(o & (~1));
7476         o_conv.is_owned = (o & 1) || (o == 0);
7477         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
7478         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7479         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7480         return (uint64_t)ret_conv;
7481 }
7482
7483 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7484         LDKDecodeError e_conv;
7485         e_conv.inner = (void*)(e & (~1));
7486         e_conv.is_owned = (e & 1) || (e == 0);
7487         e_conv = DecodeError_clone(&e_conv);
7488         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7489         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7490         return (uint64_t)ret_conv;
7491 }
7492
7493 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7494         if ((_res & 1) != 0) return;
7495         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7496         FREE((void*)_res);
7497         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7498 }
7499
7500 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7501         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7502         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7503         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7504         return (uint64_t)ret_conv;
7505 }
7506
7507 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7508         LDKStaticPaymentOutputDescriptor o_conv;
7509         o_conv.inner = (void*)(o & (~1));
7510         o_conv.is_owned = (o & 1) || (o == 0);
7511         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
7512         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7513         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7514         return (uint64_t)ret_conv;
7515 }
7516
7517 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7518         LDKDecodeError e_conv;
7519         e_conv.inner = (void*)(e & (~1));
7520         e_conv.is_owned = (e & 1) || (e == 0);
7521         e_conv = DecodeError_clone(&e_conv);
7522         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7523         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7524         return (uint64_t)ret_conv;
7525 }
7526
7527 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7528         if ((_res & 1) != 0) return;
7529         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7530         FREE((void*)_res);
7531         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7532 }
7533
7534 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7535         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7536         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7537         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7538         return (uint64_t)ret_conv;
7539 }
7540
7541 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7542         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7543         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7544         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7545         return (uint64_t)ret_conv;
7546 }
7547
7548 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7549         LDKDecodeError e_conv;
7550         e_conv.inner = (void*)(e & (~1));
7551         e_conv.is_owned = (e & 1) || (e == 0);
7552         e_conv = DecodeError_clone(&e_conv);
7553         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7554         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7555         return (uint64_t)ret_conv;
7556 }
7557
7558 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7559         if ((_res & 1) != 0) return;
7560         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7561         FREE((void*)_res);
7562         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7563 }
7564
7565 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7566         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7567         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7568         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7569         return (uint64_t)ret_conv;
7570 }
7571
7572 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7573         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7574         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7575         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7576         return (uint64_t)ret_ref;
7577 }
7578
7579 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7580         LDKSignature a_ref;
7581         CHECK(*((uint32_t*)a) == 64);
7582         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7583         LDKCVec_SignatureZ b_constr;
7584         b_constr.datalen = *((uint32_t*)b);
7585         if (b_constr.datalen > 0)
7586                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7587         else
7588                 b_constr.data = NULL;
7589         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7590         for (size_t m = 0; m < b_constr.datalen; m++) {
7591                 int8_tArray b_conv_12 = b_vals[m];
7592                 LDKSignature b_conv_12_ref;
7593                 CHECK(*((uint32_t*)b_conv_12) == 64);
7594                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7595                 b_constr.data[m] = b_conv_12_ref;
7596         }
7597         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7598         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7599         return (uint64_t)ret_ref;
7600 }
7601
7602 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7603         if ((_res & 1) != 0) return;
7604         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7605         FREE((void*)_res);
7606         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7607 }
7608
7609 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7610         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7611         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7612         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7613         return (uint64_t)ret_conv;
7614 }
7615
7616 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7617         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7618         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7619         return (uint64_t)ret_conv;
7620 }
7621
7622 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7623         if ((_res & 1) != 0) return;
7624         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7625         FREE((void*)_res);
7626         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7627 }
7628
7629 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7630         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7631         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7632         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7633         return (uint64_t)ret_conv;
7634 }
7635
7636 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7637         LDKSignature o_ref;
7638         CHECK(*((uint32_t*)o) == 64);
7639         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7640         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7641         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7642         return (uint64_t)ret_conv;
7643 }
7644
7645 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7646         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7647         *ret_conv = CResult_SignatureNoneZ_err();
7648         return (uint64_t)ret_conv;
7649 }
7650
7651 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7652         if ((_res & 1) != 0) return;
7653         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7654         FREE((void*)_res);
7655         CResult_SignatureNoneZ_free(_res_conv);
7656 }
7657
7658 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7659         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7660         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7661         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7662         return (uint64_t)ret_conv;
7663 }
7664
7665 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7666         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7667         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7668         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7669         return (uint64_t)ret_conv;
7670 }
7671
7672 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7673         LDKDecodeError e_conv;
7674         e_conv.inner = (void*)(e & (~1));
7675         e_conv.is_owned = (e & 1) || (e == 0);
7676         e_conv = DecodeError_clone(&e_conv);
7677         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7678         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7679         return (uint64_t)ret_conv;
7680 }
7681
7682 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7683         if ((_res & 1) != 0) return;
7684         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7685         FREE((void*)_res);
7686         CResult_SignDecodeErrorZ_free(_res_conv);
7687 }
7688
7689 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7690         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7691         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7692         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7693         return (uint64_t)ret_conv;
7694 }
7695
7696 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
7697         LDKCVec_u8Z _res_ref;
7698         _res_ref.datalen = *((uint32_t*)_res);
7699         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7700         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7701         CVec_u8Z_free(_res_ref);
7702 }
7703
7704 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
7705         LDKRecoverableSignature arg_ref;
7706         CHECK(*((uint32_t*)arg) == 68);
7707         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
7708         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7709         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
7710         return (uint64_t)ret_conv;
7711 }
7712
7713 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
7714         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7715         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
7716         return (uint64_t)ret_conv;
7717 }
7718
7719 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
7720         if ((_res & 1) != 0) return;
7721         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
7722         FREE((void*)_res);
7723         CResult_RecoverableSignatureNoneZ_free(_res_conv);
7724 }
7725
7726 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
7727         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
7728         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7729         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
7730         return (uint64_t)ret_conv;
7731 }
7732
7733 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7734         LDKCVec_CVec_u8ZZ _res_constr;
7735         _res_constr.datalen = *((uint32_t*)_res);
7736         if (_res_constr.datalen > 0)
7737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7738         else
7739                 _res_constr.data = NULL;
7740         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7741         for (size_t m = 0; m < _res_constr.datalen; m++) {
7742                 int8_tArray _res_conv_12 = _res_vals[m];
7743                 LDKCVec_u8Z _res_conv_12_ref;
7744                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7745                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7746                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7747                 _res_constr.data[m] = _res_conv_12_ref;
7748         }
7749         CVec_CVec_u8ZZ_free(_res_constr);
7750 }
7751
7752 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7753         LDKCVec_CVec_u8ZZ o_constr;
7754         o_constr.datalen = *((uint32_t*)o);
7755         if (o_constr.datalen > 0)
7756                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7757         else
7758                 o_constr.data = NULL;
7759         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7760         for (size_t m = 0; m < o_constr.datalen; m++) {
7761                 int8_tArray o_conv_12 = o_vals[m];
7762                 LDKCVec_u8Z o_conv_12_ref;
7763                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7764                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7765                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7766                 o_constr.data[m] = o_conv_12_ref;
7767         }
7768         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7769         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7770         return (uint64_t)ret_conv;
7771 }
7772
7773 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7774         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7775         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7776         return (uint64_t)ret_conv;
7777 }
7778
7779 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7780         if ((_res & 1) != 0) return;
7781         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7782         FREE((void*)_res);
7783         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7784 }
7785
7786 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7787         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7788         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7789         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7790         return (uint64_t)ret_conv;
7791 }
7792
7793 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7794         LDKInMemorySigner o_conv;
7795         o_conv.inner = (void*)(o & (~1));
7796         o_conv.is_owned = (o & 1) || (o == 0);
7797         o_conv = InMemorySigner_clone(&o_conv);
7798         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7799         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7800         return (uint64_t)ret_conv;
7801 }
7802
7803 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7804         LDKDecodeError e_conv;
7805         e_conv.inner = (void*)(e & (~1));
7806         e_conv.is_owned = (e & 1) || (e == 0);
7807         e_conv = DecodeError_clone(&e_conv);
7808         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7809         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7810         return (uint64_t)ret_conv;
7811 }
7812
7813 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7814         if ((_res & 1) != 0) return;
7815         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7816         FREE((void*)_res);
7817         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7818 }
7819
7820 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7821         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7822         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7823         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7824         return (uint64_t)ret_conv;
7825 }
7826
7827 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7828         LDKCVec_TxOutZ _res_constr;
7829         _res_constr.datalen = *((uint32_t*)_res);
7830         if (_res_constr.datalen > 0)
7831                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7832         else
7833                 _res_constr.data = NULL;
7834         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7835         for (size_t h = 0; h < _res_constr.datalen; h++) {
7836                 uint32_t _res_conv_7 = _res_vals[h];
7837                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7838                 FREE((void*)_res_conv_7);
7839                 _res_constr.data[h] = _res_conv_7_conv;
7840         }
7841         CVec_TxOutZ_free(_res_constr);
7842 }
7843
7844 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7845         LDKTransaction o_ref;
7846         o_ref.datalen = *((uint32_t*)o);
7847         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7848         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7849         o_ref.data_is_owned = true;
7850         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7851         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7852         return (uint64_t)ret_conv;
7853 }
7854
7855 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7856         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7857         *ret_conv = CResult_TransactionNoneZ_err();
7858         return (uint64_t)ret_conv;
7859 }
7860
7861 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7862         if ((_res & 1) != 0) return;
7863         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7864         FREE((void*)_res);
7865         CResult_TransactionNoneZ_free(_res_conv);
7866 }
7867
7868 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
7869         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
7870         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7871         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
7872         return (uint64_t)ret_conv;
7873 }
7874
7875 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
7876         LDKThirtyTwoBytes a_ref;
7877         CHECK(*((uint32_t*)a) == 32);
7878         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7879         LDKChannelMonitor b_conv;
7880         b_conv.inner = (void*)(b & (~1));
7881         b_conv.is_owned = (b & 1) || (b == 0);
7882         b_conv = ChannelMonitor_clone(&b_conv);
7883         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7884         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7885         return (uint64_t)ret_ref;
7886 }
7887
7888 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
7889         if ((_res & 1) != 0) return;
7890         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7891         FREE((void*)_res);
7892         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7893 }
7894
7895 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
7896         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
7897         _res_constr.datalen = *((uint32_t*)_res);
7898         if (_res_constr.datalen > 0)
7899                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7900         else
7901                 _res_constr.data = NULL;
7902         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7903         for (size_t m = 0; m < _res_constr.datalen; m++) {
7904                 uint32_t _res_conv_38 = _res_vals[m];
7905                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
7906                 FREE((void*)_res_conv_38);
7907                 _res_constr.data[m] = _res_conv_38_conv;
7908         }
7909         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
7910 }
7911
7912 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
7913         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
7914         o_constr.datalen = *((uint32_t*)o);
7915         if (o_constr.datalen > 0)
7916                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7917         else
7918                 o_constr.data = NULL;
7919         uint32_t* o_vals = (uint32_t*)(o + 4);
7920         for (size_t m = 0; m < o_constr.datalen; m++) {
7921                 uint32_t o_conv_38 = o_vals[m];
7922                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
7923                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
7924                 o_constr.data[m] = o_conv_38_conv;
7925         }
7926         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7927         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
7928         return (uint64_t)ret_conv;
7929 }
7930
7931 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
7932         LDKIOError e_conv = LDKIOError_from_js(e);
7933         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7934         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
7935         return (uint64_t)ret_conv;
7936 }
7937
7938 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
7939         if ((_res & 1) != 0) return;
7940         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
7941         FREE((void*)_res);
7942         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
7943 }
7944
7945 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
7946         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7947         *ret_copy = COption_u16Z_some(o);
7948         uint64_t ret_ref = (uint64_t)ret_copy;
7949         return ret_ref;
7950 }
7951
7952 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
7953         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7954         *ret_copy = COption_u16Z_none();
7955         uint64_t ret_ref = (uint64_t)ret_copy;
7956         return ret_ref;
7957 }
7958
7959 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
7960         if ((_res & 1) != 0) return;
7961         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
7962         FREE((void*)_res);
7963         COption_u16Z_free(_res_conv);
7964 }
7965
7966 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
7967         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
7968         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
7969         *ret_copy = COption_u16Z_clone(orig_conv);
7970         uint64_t ret_ref = (uint64_t)ret_copy;
7971         return ret_ref;
7972 }
7973
7974 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
7975         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7976         *ret_conv = CResult_NoneAPIErrorZ_ok();
7977         return (uint64_t)ret_conv;
7978 }
7979
7980 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
7981         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7982         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7983         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7984         return (uint64_t)ret_conv;
7985 }
7986
7987 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
7988         if ((_res & 1) != 0) return;
7989         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7990         FREE((void*)_res);
7991         CResult_NoneAPIErrorZ_free(_res_conv);
7992 }
7993
7994 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
7995         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7996         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7997         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7998         return (uint64_t)ret_conv;
7999 }
8000
8001 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8002         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8003         _res_constr.datalen = *((uint32_t*)_res);
8004         if (_res_constr.datalen > 0)
8005                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8006         else
8007                 _res_constr.data = NULL;
8008         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8009         for (size_t w = 0; w < _res_constr.datalen; w++) {
8010                 uint32_t _res_conv_22 = _res_vals[w];
8011                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8012                 FREE((void*)_res_conv_22);
8013                 _res_constr.data[w] = _res_conv_22_conv;
8014         }
8015         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8016 }
8017
8018 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
8019         LDKCVec_APIErrorZ _res_constr;
8020         _res_constr.datalen = *((uint32_t*)_res);
8021         if (_res_constr.datalen > 0)
8022                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8023         else
8024                 _res_constr.data = NULL;
8025         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8026         for (size_t k = 0; k < _res_constr.datalen; k++) {
8027                 uint32_t _res_conv_10 = _res_vals[k];
8028                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8029                 FREE((void*)_res_conv_10);
8030                 _res_constr.data[k] = _res_conv_10_conv;
8031         }
8032         CVec_APIErrorZ_free(_res_constr);
8033 }
8034
8035 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
8036         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8037         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8038         return (uint64_t)ret_conv;
8039 }
8040
8041 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
8042         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8043         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8044         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8045         return (uint64_t)ret_conv;
8046 }
8047
8048 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
8049         if ((_res & 1) != 0) return;
8050         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
8051         FREE((void*)_res);
8052         CResult_NonePaymentSendFailureZ_free(_res_conv);
8053 }
8054
8055 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8056         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8057         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8058         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8059         return (uint64_t)ret_conv;
8060 }
8061
8062 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8063         LDKCVec_NetAddressZ _res_constr;
8064         _res_constr.datalen = *((uint32_t*)_res);
8065         if (_res_constr.datalen > 0)
8066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8067         else
8068                 _res_constr.data = NULL;
8069         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8070         for (size_t m = 0; m < _res_constr.datalen; m++) {
8071                 uint32_t _res_conv_12 = _res_vals[m];
8072                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8073                 FREE((void*)_res_conv_12);
8074                 _res_constr.data[m] = _res_conv_12_conv;
8075         }
8076         CVec_NetAddressZ_free(_res_constr);
8077 }
8078
8079 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8080         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8081         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8082         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8083         return (uint64_t)ret_ref;
8084 }
8085
8086 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8087         LDKThirtyTwoBytes a_ref;
8088         CHECK(*((uint32_t*)a) == 32);
8089         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8090         LDKThirtyTwoBytes b_ref;
8091         CHECK(*((uint32_t*)b) == 32);
8092         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8093         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8094         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8095         return (uint64_t)ret_ref;
8096 }
8097
8098 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8099         if ((_res & 1) != 0) return;
8100         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8101         FREE((void*)_res);
8102         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8103 }
8104
8105 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8106         LDKThirtyTwoBytes o_ref;
8107         CHECK(*((uint32_t*)o) == 32);
8108         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8109         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8110         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8111         return (uint64_t)ret_conv;
8112 }
8113
8114 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8115         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8116         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8117         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8118         return (uint64_t)ret_conv;
8119 }
8120
8121 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8122         if ((_res & 1) != 0) return;
8123         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8124         FREE((void*)_res);
8125         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8126 }
8127
8128 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8129         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8130         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8131         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8132         return (uint64_t)ret_conv;
8133 }
8134
8135 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8136         LDKCVec_ChannelMonitorZ _res_constr;
8137         _res_constr.datalen = *((uint32_t*)_res);
8138         if (_res_constr.datalen > 0)
8139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8140         else
8141                 _res_constr.data = NULL;
8142         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8143         for (size_t q = 0; q < _res_constr.datalen; q++) {
8144                 uint32_t _res_conv_16 = _res_vals[q];
8145                 LDKChannelMonitor _res_conv_16_conv;
8146                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8147                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8148                 _res_constr.data[q] = _res_conv_16_conv;
8149         }
8150         CVec_ChannelMonitorZ_free(_res_constr);
8151 }
8152
8153 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8154         LDKThirtyTwoBytes a_ref;
8155         CHECK(*((uint32_t*)a) == 32);
8156         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8157         LDKChannelManager b_conv;
8158         b_conv.inner = (void*)(b & (~1));
8159         b_conv.is_owned = (b & 1) || (b == 0);
8160         // Warning: we need a move here but no clone is available for LDKChannelManager
8161         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8162         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8163         return (uint64_t)ret_ref;
8164 }
8165
8166 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8167         if ((_res & 1) != 0) return;
8168         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8169         FREE((void*)_res);
8170         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8171 }
8172
8173 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8174         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8175         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8176         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8177         return (uint64_t)ret_conv;
8178 }
8179
8180 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8181         LDKDecodeError e_conv;
8182         e_conv.inner = (void*)(e & (~1));
8183         e_conv.is_owned = (e & 1) || (e == 0);
8184         e_conv = DecodeError_clone(&e_conv);
8185         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8186         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8187         return (uint64_t)ret_conv;
8188 }
8189
8190 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8191         if ((_res & 1) != 0) return;
8192         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8193         FREE((void*)_res);
8194         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8195 }
8196
8197 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8198         LDKChannelConfig o_conv;
8199         o_conv.inner = (void*)(o & (~1));
8200         o_conv.is_owned = (o & 1) || (o == 0);
8201         o_conv = ChannelConfig_clone(&o_conv);
8202         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8203         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8204         return (uint64_t)ret_conv;
8205 }
8206
8207 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8208         LDKDecodeError e_conv;
8209         e_conv.inner = (void*)(e & (~1));
8210         e_conv.is_owned = (e & 1) || (e == 0);
8211         e_conv = DecodeError_clone(&e_conv);
8212         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8213         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
8214         return (uint64_t)ret_conv;
8215 }
8216
8217 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
8218         if ((_res & 1) != 0) return;
8219         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
8220         FREE((void*)_res);
8221         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
8222 }
8223
8224 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
8225         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
8226         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8227         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
8228         return (uint64_t)ret_conv;
8229 }
8230
8231 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
8232         LDKOutPoint o_conv;
8233         o_conv.inner = (void*)(o & (~1));
8234         o_conv.is_owned = (o & 1) || (o == 0);
8235         o_conv = OutPoint_clone(&o_conv);
8236         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8237         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
8238         return (uint64_t)ret_conv;
8239 }
8240
8241 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
8242         LDKDecodeError e_conv;
8243         e_conv.inner = (void*)(e & (~1));
8244         e_conv.is_owned = (e & 1) || (e == 0);
8245         e_conv = DecodeError_clone(&e_conv);
8246         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8247         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
8248         return (uint64_t)ret_conv;
8249 }
8250
8251 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
8252         if ((_res & 1) != 0) return;
8253         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
8254         FREE((void*)_res);
8255         CResult_OutPointDecodeErrorZ_free(_res_conv);
8256 }
8257
8258 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
8259         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
8260         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8261         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
8262         return (uint64_t)ret_conv;
8263 }
8264
8265 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
8266         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
8267         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8268         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
8269         return (uint64_t)ret_conv;
8270 }
8271
8272 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
8273         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8274         *ret_conv = CResult_SiPrefixNoneZ_err();
8275         return (uint64_t)ret_conv;
8276 }
8277
8278 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
8279         if ((_res & 1) != 0) return;
8280         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
8281         FREE((void*)_res);
8282         CResult_SiPrefixNoneZ_free(_res_conv);
8283 }
8284
8285 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
8286         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
8287         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8288         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
8289         return (uint64_t)ret_conv;
8290 }
8291
8292 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
8293         LDKInvoice o_conv;
8294         o_conv.inner = (void*)(o & (~1));
8295         o_conv.is_owned = (o & 1) || (o == 0);
8296         o_conv = Invoice_clone(&o_conv);
8297         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8298         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
8299         return (uint64_t)ret_conv;
8300 }
8301
8302 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
8303         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8304         *ret_conv = CResult_InvoiceNoneZ_err();
8305         return (uint64_t)ret_conv;
8306 }
8307
8308 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
8309         if ((_res & 1) != 0) return;
8310         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
8311         FREE((void*)_res);
8312         CResult_InvoiceNoneZ_free(_res_conv);
8313 }
8314
8315 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
8316         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
8317         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8318         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
8319         return (uint64_t)ret_conv;
8320 }
8321
8322 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
8323         LDKSignedRawInvoice o_conv;
8324         o_conv.inner = (void*)(o & (~1));
8325         o_conv.is_owned = (o & 1) || (o == 0);
8326         o_conv = SignedRawInvoice_clone(&o_conv);
8327         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8328         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
8329         return (uint64_t)ret_conv;
8330 }
8331
8332 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
8333         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8334         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
8335         return (uint64_t)ret_conv;
8336 }
8337
8338 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
8339         if ((_res & 1) != 0) return;
8340         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
8341         FREE((void*)_res);
8342         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
8343 }
8344
8345 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
8346         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
8347         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8348         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
8349         return (uint64_t)ret_conv;
8350 }
8351
8352 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
8353         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
8354         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8355         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
8356         return (uint64_t)ret_ref;
8357 }
8358
8359 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
8360         LDKRawInvoice a_conv;
8361         a_conv.inner = (void*)(a & (~1));
8362         a_conv.is_owned = (a & 1) || (a == 0);
8363         a_conv = RawInvoice_clone(&a_conv);
8364         LDKThirtyTwoBytes b_ref;
8365         CHECK(*((uint32_t*)b) == 32);
8366         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8367         LDKInvoiceSignature c_conv;
8368         c_conv.inner = (void*)(c & (~1));
8369         c_conv.is_owned = (c & 1) || (c == 0);
8370         c_conv = InvoiceSignature_clone(&c_conv);
8371         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8372         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
8373         return (uint64_t)ret_ref;
8374 }
8375
8376 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
8377         if ((_res & 1) != 0) return;
8378         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
8379         FREE((void*)_res);
8380         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
8381 }
8382
8383 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
8384         LDKPayeePubKey o_conv;
8385         o_conv.inner = (void*)(o & (~1));
8386         o_conv.is_owned = (o & 1) || (o == 0);
8387         o_conv = PayeePubKey_clone(&o_conv);
8388         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8389         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
8390         return (uint64_t)ret_conv;
8391 }
8392
8393 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
8394         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8395         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8396         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
8397         return (uint64_t)ret_conv;
8398 }
8399
8400 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
8401         if ((_res & 1) != 0) return;
8402         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
8403         FREE((void*)_res);
8404         CResult_PayeePubKeyErrorZ_free(_res_conv);
8405 }
8406
8407 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
8408         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
8409         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8410         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
8411         return (uint64_t)ret_conv;
8412 }
8413
8414 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
8415         LDKCVec_PrivateRouteZ _res_constr;
8416         _res_constr.datalen = *((uint32_t*)_res);
8417         if (_res_constr.datalen > 0)
8418                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
8419         else
8420                 _res_constr.data = NULL;
8421         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8422         for (size_t o = 0; o < _res_constr.datalen; o++) {
8423                 uint32_t _res_conv_14 = _res_vals[o];
8424                 LDKPrivateRoute _res_conv_14_conv;
8425                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
8426                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
8427                 _res_constr.data[o] = _res_conv_14_conv;
8428         }
8429         CVec_PrivateRouteZ_free(_res_constr);
8430 }
8431
8432 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
8433         LDKPositiveTimestamp o_conv;
8434         o_conv.inner = (void*)(o & (~1));
8435         o_conv.is_owned = (o & 1) || (o == 0);
8436         o_conv = PositiveTimestamp_clone(&o_conv);
8437         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8438         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
8439         return (uint64_t)ret_conv;
8440 }
8441
8442 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
8443         LDKCreationError e_conv = LDKCreationError_from_js(e);
8444         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8445         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
8446         return (uint64_t)ret_conv;
8447 }
8448
8449 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
8450         if ((_res & 1) != 0) return;
8451         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
8452         FREE((void*)_res);
8453         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
8454 }
8455
8456 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
8457         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
8458         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8459         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
8460         return (uint64_t)ret_conv;
8461 }
8462
8463 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
8464         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8465         *ret_conv = CResult_NoneSemanticErrorZ_ok();
8466         return (uint64_t)ret_conv;
8467 }
8468
8469 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
8470         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8471         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8472         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
8473         return (uint64_t)ret_conv;
8474 }
8475
8476 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
8477         if ((_res & 1) != 0) return;
8478         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
8479         FREE((void*)_res);
8480         CResult_NoneSemanticErrorZ_free(_res_conv);
8481 }
8482
8483 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
8484         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
8485         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8486         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
8487         return (uint64_t)ret_conv;
8488 }
8489
8490 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
8491         LDKInvoice o_conv;
8492         o_conv.inner = (void*)(o & (~1));
8493         o_conv.is_owned = (o & 1) || (o == 0);
8494         o_conv = Invoice_clone(&o_conv);
8495         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8496         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
8497         return (uint64_t)ret_conv;
8498 }
8499
8500 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
8501         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8502         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8503         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
8504         return (uint64_t)ret_conv;
8505 }
8506
8507 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
8508         if ((_res & 1) != 0) return;
8509         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
8510         FREE((void*)_res);
8511         CResult_InvoiceSemanticErrorZ_free(_res_conv);
8512 }
8513
8514 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
8515         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
8516         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8517         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
8518         return (uint64_t)ret_conv;
8519 }
8520
8521 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
8522         LDKDescription o_conv;
8523         o_conv.inner = (void*)(o & (~1));
8524         o_conv.is_owned = (o & 1) || (o == 0);
8525         o_conv = Description_clone(&o_conv);
8526         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8527         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
8528         return (uint64_t)ret_conv;
8529 }
8530
8531 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
8532         LDKCreationError e_conv = LDKCreationError_from_js(e);
8533         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8534         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
8535         return (uint64_t)ret_conv;
8536 }
8537
8538 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
8539         if ((_res & 1) != 0) return;
8540         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
8541         FREE((void*)_res);
8542         CResult_DescriptionCreationErrorZ_free(_res_conv);
8543 }
8544
8545 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
8546         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
8547         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8548         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
8549         return (uint64_t)ret_conv;
8550 }
8551
8552 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
8553         LDKExpiryTime o_conv;
8554         o_conv.inner = (void*)(o & (~1));
8555         o_conv.is_owned = (o & 1) || (o == 0);
8556         o_conv = ExpiryTime_clone(&o_conv);
8557         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8558         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
8559         return (uint64_t)ret_conv;
8560 }
8561
8562 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
8563         LDKCreationError e_conv = LDKCreationError_from_js(e);
8564         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8565         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
8566         return (uint64_t)ret_conv;
8567 }
8568
8569 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
8570         if ((_res & 1) != 0) return;
8571         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
8572         FREE((void*)_res);
8573         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
8574 }
8575
8576 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
8577         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
8578         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8579         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
8580         return (uint64_t)ret_conv;
8581 }
8582
8583 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
8584         LDKPrivateRoute o_conv;
8585         o_conv.inner = (void*)(o & (~1));
8586         o_conv.is_owned = (o & 1) || (o == 0);
8587         o_conv = PrivateRoute_clone(&o_conv);
8588         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8589         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
8590         return (uint64_t)ret_conv;
8591 }
8592
8593 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
8594         LDKCreationError e_conv = LDKCreationError_from_js(e);
8595         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8596         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
8597         return (uint64_t)ret_conv;
8598 }
8599
8600 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
8601         if ((_res & 1) != 0) return;
8602         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
8603         FREE((void*)_res);
8604         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
8605 }
8606
8607 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
8608         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
8609         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8610         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
8611         return (uint64_t)ret_conv;
8612 }
8613
8614 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
8615         LDKStr o_conv = str_ref_to_owned_c(o);
8616         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8617         *ret_conv = CResult_StringErrorZ_ok(o_conv);
8618         return (uint64_t)ret_conv;
8619 }
8620
8621 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
8622         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8623         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8624         *ret_conv = CResult_StringErrorZ_err(e_conv);
8625         return (uint64_t)ret_conv;
8626 }
8627
8628 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
8629         if ((_res & 1) != 0) return;
8630         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
8631         FREE((void*)_res);
8632         CResult_StringErrorZ_free(_res_conv);
8633 }
8634
8635 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
8636         LDKChannelMonitorUpdate o_conv;
8637         o_conv.inner = (void*)(o & (~1));
8638         o_conv.is_owned = (o & 1) || (o == 0);
8639         o_conv = ChannelMonitorUpdate_clone(&o_conv);
8640         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8641         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
8642         return (uint64_t)ret_conv;
8643 }
8644
8645 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
8646         LDKDecodeError e_conv;
8647         e_conv.inner = (void*)(e & (~1));
8648         e_conv.is_owned = (e & 1) || (e == 0);
8649         e_conv = DecodeError_clone(&e_conv);
8650         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8651         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
8652         return (uint64_t)ret_conv;
8653 }
8654
8655 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
8656         if ((_res & 1) != 0) return;
8657         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8658         FREE((void*)_res);
8659         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
8660 }
8661
8662 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
8663         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
8664         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8665         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
8666         return (uint64_t)ret_conv;
8667 }
8668
8669 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
8670         LDKHTLCUpdate o_conv;
8671         o_conv.inner = (void*)(o & (~1));
8672         o_conv.is_owned = (o & 1) || (o == 0);
8673         o_conv = HTLCUpdate_clone(&o_conv);
8674         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8675         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
8676         return (uint64_t)ret_conv;
8677 }
8678
8679 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
8680         LDKDecodeError e_conv;
8681         e_conv.inner = (void*)(e & (~1));
8682         e_conv.is_owned = (e & 1) || (e == 0);
8683         e_conv = DecodeError_clone(&e_conv);
8684         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8685         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
8686         return (uint64_t)ret_conv;
8687 }
8688
8689 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
8690         if ((_res & 1) != 0) return;
8691         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8692         FREE((void*)_res);
8693         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
8694 }
8695
8696 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
8697         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
8698         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8699         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
8700         return (uint64_t)ret_conv;
8701 }
8702
8703 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
8704         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8705         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
8706         return (uint64_t)ret_conv;
8707 }
8708
8709 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
8710         LDKMonitorUpdateError e_conv;
8711         e_conv.inner = (void*)(e & (~1));
8712         e_conv.is_owned = (e & 1) || (e == 0);
8713         e_conv = MonitorUpdateError_clone(&e_conv);
8714         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8715         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
8716         return (uint64_t)ret_conv;
8717 }
8718
8719 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
8720         if ((_res & 1) != 0) return;
8721         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
8722         FREE((void*)_res);
8723         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
8724 }
8725
8726 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
8727         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
8728         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8729         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
8730         return (uint64_t)ret_conv;
8731 }
8732
8733 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
8734         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
8735         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8736         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
8737         return (uint64_t)ret_ref;
8738 }
8739
8740 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
8741         LDKOutPoint a_conv;
8742         a_conv.inner = (void*)(a & (~1));
8743         a_conv.is_owned = (a & 1) || (a == 0);
8744         a_conv = OutPoint_clone(&a_conv);
8745         LDKCVec_u8Z b_ref;
8746         b_ref.datalen = *((uint32_t*)b);
8747         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8748         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8749         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8750         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
8751         return (uint64_t)ret_ref;
8752 }
8753
8754 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
8755         if ((_res & 1) != 0) return;
8756         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
8757         FREE((void*)_res);
8758         C2Tuple_OutPointScriptZ_free(_res_conv);
8759 }
8760
8761 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
8762         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
8763         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8764         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
8765         return (uint64_t)ret_ref;
8766 }
8767
8768 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
8769         LDKCVec_u8Z b_ref;
8770         b_ref.datalen = *((uint32_t*)b);
8771         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8772         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8773         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8774         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
8775         return (uint64_t)ret_ref;
8776 }
8777
8778 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
8779         if ((_res & 1) != 0) return;
8780         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
8781         FREE((void*)_res);
8782         C2Tuple_u32ScriptZ_free(_res_conv);
8783 }
8784
8785 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
8786         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
8787         _res_constr.datalen = *((uint32_t*)_res);
8788         if (_res_constr.datalen > 0)
8789                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8790         else
8791                 _res_constr.data = NULL;
8792         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8793         for (size_t e = 0; e < _res_constr.datalen; e++) {
8794                 uint32_t _res_conv_30 = _res_vals[e];
8795                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
8796                 FREE((void*)_res_conv_30);
8797                 _res_constr.data[e] = _res_conv_30_conv;
8798         }
8799         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
8800 }
8801
8802 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
8803         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
8804         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8805         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
8806         return (uint64_t)ret_ref;
8807 }
8808
8809 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
8810         LDKThirtyTwoBytes a_ref;
8811         CHECK(*((uint32_t*)a) == 32);
8812         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8813         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
8814         b_constr.datalen = *((uint32_t*)b);
8815         if (b_constr.datalen > 0)
8816                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8817         else
8818                 b_constr.data = NULL;
8819         uint32_t* b_vals = (uint32_t*)(b + 4);
8820         for (size_t e = 0; e < b_constr.datalen; e++) {
8821                 uint32_t b_conv_30 = b_vals[e];
8822                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
8823                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
8824                 b_constr.data[e] = b_conv_30_conv;
8825         }
8826         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8827         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
8828         return (uint64_t)ret_ref;
8829 }
8830
8831 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
8832         if ((_res & 1) != 0) return;
8833         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
8834         FREE((void*)_res);
8835         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
8836 }
8837
8838 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
8839         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
8840         _res_constr.datalen = *((uint32_t*)_res);
8841         if (_res_constr.datalen > 0)
8842                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
8843         else
8844                 _res_constr.data = NULL;
8845         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8846         for (size_t c = 0; c < _res_constr.datalen; c++) {
8847                 uint32_t _res_conv_54 = _res_vals[c];
8848                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
8849                 FREE((void*)_res_conv_54);
8850                 _res_constr.data[c] = _res_conv_54_conv;
8851         }
8852         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
8853 }
8854
8855 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
8856         LDKCVec_EventZ _res_constr;
8857         _res_constr.datalen = *((uint32_t*)_res);
8858         if (_res_constr.datalen > 0)
8859                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ 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                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
8866                 FREE((void*)_res_conv_7);
8867                 _res_constr.data[h] = _res_conv_7_conv;
8868         }
8869         CVec_EventZ_free(_res_constr);
8870 }
8871
8872 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
8873         LDKCVec_TransactionZ _res_constr;
8874         _res_constr.datalen = *((uint32_t*)_res);
8875         if (_res_constr.datalen > 0)
8876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
8877         else
8878                 _res_constr.data = NULL;
8879         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8880         for (size_t m = 0; m < _res_constr.datalen; m++) {
8881                 int8_tArray _res_conv_12 = _res_vals[m];
8882                 LDKTransaction _res_conv_12_ref;
8883                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8884                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
8885                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8886                 _res_conv_12_ref.data_is_owned = true;
8887                 _res_constr.data[m] = _res_conv_12_ref;
8888         }
8889         CVec_TransactionZ_free(_res_constr);
8890 }
8891
8892 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
8893         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
8894         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8895         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
8896         return (uint64_t)ret_ref;
8897 }
8898
8899 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
8900         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
8901         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8902         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
8903         return (uint64_t)ret_ref;
8904 }
8905
8906 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
8907         if ((_res & 1) != 0) return;
8908         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
8909         FREE((void*)_res);
8910         C2Tuple_u32TxOutZ_free(_res_conv);
8911 }
8912
8913 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
8914         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
8915         _res_constr.datalen = *((uint32_t*)_res);
8916         if (_res_constr.datalen > 0)
8917                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8918         else
8919                 _res_constr.data = NULL;
8920         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8921         for (size_t z = 0; z < _res_constr.datalen; z++) {
8922                 uint32_t _res_conv_25 = _res_vals[z];
8923                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
8924                 FREE((void*)_res_conv_25);
8925                 _res_constr.data[z] = _res_conv_25_conv;
8926         }
8927         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
8928 }
8929
8930 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
8931         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
8932         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8933         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
8934         return (uint64_t)ret_ref;
8935 }
8936
8937 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
8938         LDKThirtyTwoBytes a_ref;
8939         CHECK(*((uint32_t*)a) == 32);
8940         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8941         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
8942         b_constr.datalen = *((uint32_t*)b);
8943         if (b_constr.datalen > 0)
8944                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8945         else
8946                 b_constr.data = NULL;
8947         uint32_t* b_vals = (uint32_t*)(b + 4);
8948         for (size_t z = 0; z < b_constr.datalen; z++) {
8949                 uint32_t b_conv_25 = b_vals[z];
8950                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
8951                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
8952                 b_constr.data[z] = b_conv_25_conv;
8953         }
8954         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8955         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
8956         return (uint64_t)ret_ref;
8957 }
8958
8959 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
8960         if ((_res & 1) != 0) return;
8961         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
8962         FREE((void*)_res);
8963         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
8964 }
8965
8966 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
8967         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
8968         _res_constr.datalen = *((uint32_t*)_res);
8969         if (_res_constr.datalen > 0)
8970                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
8971         else
8972                 _res_constr.data = NULL;
8973         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8974         for (size_t x = 0; x < _res_constr.datalen; x++) {
8975                 uint32_t _res_conv_49 = _res_vals[x];
8976                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
8977                 FREE((void*)_res_conv_49);
8978                 _res_constr.data[x] = _res_conv_49_conv;
8979         }
8980         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
8981 }
8982
8983 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
8984         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
8985         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8986         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
8987         return (uint64_t)ret_conv;
8988 }
8989
8990 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
8991         LDKDecodeError e_conv;
8992         e_conv.inner = (void*)(e & (~1));
8993         e_conv.is_owned = (e & 1) || (e == 0);
8994         e_conv = DecodeError_clone(&e_conv);
8995         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8996         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
8997         return (uint64_t)ret_conv;
8998 }
8999
9000 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
9001         if ((_res & 1) != 0) return;
9002         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9003         FREE((void*)_res);
9004         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
9005 }
9006
9007 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
9008         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9009         *ret_conv = CResult_boolLightningErrorZ_ok(o);
9010         return (uint64_t)ret_conv;
9011 }
9012
9013 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
9014         LDKLightningError e_conv;
9015         e_conv.inner = (void*)(e & (~1));
9016         e_conv.is_owned = (e & 1) || (e == 0);
9017         e_conv = LightningError_clone(&e_conv);
9018         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9019         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
9020         return (uint64_t)ret_conv;
9021 }
9022
9023 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
9024         if ((_res & 1) != 0) return;
9025         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
9026         FREE((void*)_res);
9027         CResult_boolLightningErrorZ_free(_res_conv);
9028 }
9029
9030 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
9031         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
9032         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9033         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
9034         return (uint64_t)ret_conv;
9035 }
9036
9037 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
9038         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
9039         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9040         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
9041         return (uint64_t)ret_ref;
9042 }
9043
9044 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
9045         LDKChannelAnnouncement a_conv;
9046         a_conv.inner = (void*)(a & (~1));
9047         a_conv.is_owned = (a & 1) || (a == 0);
9048         a_conv = ChannelAnnouncement_clone(&a_conv);
9049         LDKChannelUpdate b_conv;
9050         b_conv.inner = (void*)(b & (~1));
9051         b_conv.is_owned = (b & 1) || (b == 0);
9052         b_conv = ChannelUpdate_clone(&b_conv);
9053         LDKChannelUpdate c_conv;
9054         c_conv.inner = (void*)(c & (~1));
9055         c_conv.is_owned = (c & 1) || (c == 0);
9056         c_conv = ChannelUpdate_clone(&c_conv);
9057         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9058         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
9059         return (uint64_t)ret_ref;
9060 }
9061
9062 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
9063         if ((_res & 1) != 0) return;
9064         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
9065         FREE((void*)_res);
9066         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
9067 }
9068
9069 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
9070         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
9071         _res_constr.datalen = *((uint32_t*)_res);
9072         if (_res_constr.datalen > 0)
9073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9074         else
9075                 _res_constr.data = NULL;
9076         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9077         for (size_t l = 0; l < _res_constr.datalen; l++) {
9078                 uint32_t _res_conv_63 = _res_vals[l];
9079                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
9080                 FREE((void*)_res_conv_63);
9081                 _res_constr.data[l] = _res_conv_63_conv;
9082         }
9083         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
9084 }
9085
9086 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
9087         LDKCVec_NodeAnnouncementZ _res_constr;
9088         _res_constr.datalen = *((uint32_t*)_res);
9089         if (_res_constr.datalen > 0)
9090                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9091         else
9092                 _res_constr.data = NULL;
9093         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9094         for (size_t s = 0; s < _res_constr.datalen; s++) {
9095                 uint32_t _res_conv_18 = _res_vals[s];
9096                 LDKNodeAnnouncement _res_conv_18_conv;
9097                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
9098                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
9099                 _res_constr.data[s] = _res_conv_18_conv;
9100         }
9101         CVec_NodeAnnouncementZ_free(_res_constr);
9102 }
9103
9104 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9105         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9106         *ret_conv = CResult_NoneLightningErrorZ_ok();
9107         return (uint64_t)ret_conv;
9108 }
9109
9110 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9111         LDKLightningError e_conv;
9112         e_conv.inner = (void*)(e & (~1));
9113         e_conv.is_owned = (e & 1) || (e == 0);
9114         e_conv = LightningError_clone(&e_conv);
9115         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9116         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9117         return (uint64_t)ret_conv;
9118 }
9119
9120 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9121         if ((_res & 1) != 0) return;
9122         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9123         FREE((void*)_res);
9124         CResult_NoneLightningErrorZ_free(_res_conv);
9125 }
9126
9127 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9128         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9129         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9130         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9131         return (uint64_t)ret_conv;
9132 }
9133
9134 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
9135         LDKCVec_PublicKeyZ _res_constr;
9136         _res_constr.datalen = *((uint32_t*)_res);
9137         if (_res_constr.datalen > 0)
9138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
9139         else
9140                 _res_constr.data = NULL;
9141         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9142         for (size_t m = 0; m < _res_constr.datalen; m++) {
9143                 int8_tArray _res_conv_12 = _res_vals[m];
9144                 LDKPublicKey _res_conv_12_ref;
9145                 CHECK(*((uint32_t*)_res_conv_12) == 33);
9146                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
9147                 _res_constr.data[m] = _res_conv_12_ref;
9148         }
9149         CVec_PublicKeyZ_free(_res_constr);
9150 }
9151
9152 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
9153         LDKCVec_u8Z o_ref;
9154         o_ref.datalen = *((uint32_t*)o);
9155         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
9156         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9157         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9158         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
9159         return (uint64_t)ret_conv;
9160 }
9161
9162 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
9163         LDKPeerHandleError e_conv;
9164         e_conv.inner = (void*)(e & (~1));
9165         e_conv.is_owned = (e & 1) || (e == 0);
9166         e_conv = PeerHandleError_clone(&e_conv);
9167         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9168         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
9169         return (uint64_t)ret_conv;
9170 }
9171
9172 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
9173         if ((_res & 1) != 0) return;
9174         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9175         FREE((void*)_res);
9176         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
9177 }
9178
9179 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
9180         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
9181         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9182         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
9183         return (uint64_t)ret_conv;
9184 }
9185
9186 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
9187         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9188         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
9189         return (uint64_t)ret_conv;
9190 }
9191
9192 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
9193         LDKPeerHandleError e_conv;
9194         e_conv.inner = (void*)(e & (~1));
9195         e_conv.is_owned = (e & 1) || (e == 0);
9196         e_conv = PeerHandleError_clone(&e_conv);
9197         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9198         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
9199         return (uint64_t)ret_conv;
9200 }
9201
9202 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
9203         if ((_res & 1) != 0) return;
9204         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9205         FREE((void*)_res);
9206         CResult_NonePeerHandleErrorZ_free(_res_conv);
9207 }
9208
9209 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
9210         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
9211         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9212         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
9213         return (uint64_t)ret_conv;
9214 }
9215
9216 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
9217         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9218         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
9219         return (uint64_t)ret_conv;
9220 }
9221
9222 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
9223         LDKPeerHandleError e_conv;
9224         e_conv.inner = (void*)(e & (~1));
9225         e_conv.is_owned = (e & 1) || (e == 0);
9226         e_conv = PeerHandleError_clone(&e_conv);
9227         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9228         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
9229         return (uint64_t)ret_conv;
9230 }
9231
9232 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
9233         if ((_res & 1) != 0) return;
9234         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9235         FREE((void*)_res);
9236         CResult_boolPeerHandleErrorZ_free(_res_conv);
9237 }
9238
9239 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
9240         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
9241         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9242         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
9243         return (uint64_t)ret_conv;
9244 }
9245
9246 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
9247         LDKDirectionalChannelInfo o_conv;
9248         o_conv.inner = (void*)(o & (~1));
9249         o_conv.is_owned = (o & 1) || (o == 0);
9250         o_conv = DirectionalChannelInfo_clone(&o_conv);
9251         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9252         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
9253         return (uint64_t)ret_conv;
9254 }
9255
9256 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
9257         LDKDecodeError e_conv;
9258         e_conv.inner = (void*)(e & (~1));
9259         e_conv.is_owned = (e & 1) || (e == 0);
9260         e_conv = DecodeError_clone(&e_conv);
9261         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9262         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
9263         return (uint64_t)ret_conv;
9264 }
9265
9266 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
9267         if ((_res & 1) != 0) return;
9268         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9269         FREE((void*)_res);
9270         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
9271 }
9272
9273 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9274         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
9275         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9276         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
9277         return (uint64_t)ret_conv;
9278 }
9279
9280 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
9281         LDKChannelInfo o_conv;
9282         o_conv.inner = (void*)(o & (~1));
9283         o_conv.is_owned = (o & 1) || (o == 0);
9284         o_conv = ChannelInfo_clone(&o_conv);
9285         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9286         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
9287         return (uint64_t)ret_conv;
9288 }
9289
9290 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
9291         LDKDecodeError e_conv;
9292         e_conv.inner = (void*)(e & (~1));
9293         e_conv.is_owned = (e & 1) || (e == 0);
9294         e_conv = DecodeError_clone(&e_conv);
9295         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9296         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
9297         return (uint64_t)ret_conv;
9298 }
9299
9300 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
9301         if ((_res & 1) != 0) return;
9302         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9303         FREE((void*)_res);
9304         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
9305 }
9306
9307 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9308         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
9309         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9310         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
9311         return (uint64_t)ret_conv;
9312 }
9313
9314 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
9315         LDKRoutingFees o_conv;
9316         o_conv.inner = (void*)(o & (~1));
9317         o_conv.is_owned = (o & 1) || (o == 0);
9318         o_conv = RoutingFees_clone(&o_conv);
9319         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9320         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
9321         return (uint64_t)ret_conv;
9322 }
9323
9324 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
9325         LDKDecodeError e_conv;
9326         e_conv.inner = (void*)(e & (~1));
9327         e_conv.is_owned = (e & 1) || (e == 0);
9328         e_conv = DecodeError_clone(&e_conv);
9329         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9330         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
9331         return (uint64_t)ret_conv;
9332 }
9333
9334 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
9335         if ((_res & 1) != 0) return;
9336         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9337         FREE((void*)_res);
9338         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
9339 }
9340
9341 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
9342         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
9343         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9344         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
9345         return (uint64_t)ret_conv;
9346 }
9347
9348 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
9349         LDKNodeAnnouncementInfo o_conv;
9350         o_conv.inner = (void*)(o & (~1));
9351         o_conv.is_owned = (o & 1) || (o == 0);
9352         o_conv = NodeAnnouncementInfo_clone(&o_conv);
9353         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9354         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
9355         return (uint64_t)ret_conv;
9356 }
9357
9358 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
9359         LDKDecodeError e_conv;
9360         e_conv.inner = (void*)(e & (~1));
9361         e_conv.is_owned = (e & 1) || (e == 0);
9362         e_conv = DecodeError_clone(&e_conv);
9363         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9364         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
9365         return (uint64_t)ret_conv;
9366 }
9367
9368 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
9369         if ((_res & 1) != 0) return;
9370         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9371         FREE((void*)_res);
9372         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
9373 }
9374
9375 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
9376         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
9377         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9378         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
9379         return (uint64_t)ret_conv;
9380 }
9381
9382 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
9383         LDKCVec_u64Z _res_constr;
9384         _res_constr.datalen = *((uint32_t*)_res);
9385         if (_res_constr.datalen > 0)
9386                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9387         else
9388                 _res_constr.data = NULL;
9389         int64_t* _res_vals = (int64_t*)(_res + 4);
9390         for (size_t i = 0; i < _res_constr.datalen; i++) {
9391                 int64_t _res_conv_8 = _res_vals[i];
9392                 _res_constr.data[i] = _res_conv_8;
9393         }
9394         CVec_u64Z_free(_res_constr);
9395 }
9396
9397 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
9398         LDKNodeInfo o_conv;
9399         o_conv.inner = (void*)(o & (~1));
9400         o_conv.is_owned = (o & 1) || (o == 0);
9401         o_conv = NodeInfo_clone(&o_conv);
9402         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9403         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
9404         return (uint64_t)ret_conv;
9405 }
9406
9407 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
9408         LDKDecodeError e_conv;
9409         e_conv.inner = (void*)(e & (~1));
9410         e_conv.is_owned = (e & 1) || (e == 0);
9411         e_conv = DecodeError_clone(&e_conv);
9412         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9413         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
9414         return (uint64_t)ret_conv;
9415 }
9416
9417 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
9418         if ((_res & 1) != 0) return;
9419         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9420         FREE((void*)_res);
9421         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
9422 }
9423
9424 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
9425         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
9426         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9427         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
9428         return (uint64_t)ret_conv;
9429 }
9430
9431 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
9432         LDKNetworkGraph o_conv;
9433         o_conv.inner = (void*)(o & (~1));
9434         o_conv.is_owned = (o & 1) || (o == 0);
9435         o_conv = NetworkGraph_clone(&o_conv);
9436         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9437         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
9438         return (uint64_t)ret_conv;
9439 }
9440
9441 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
9442         LDKDecodeError e_conv;
9443         e_conv.inner = (void*)(e & (~1));
9444         e_conv.is_owned = (e & 1) || (e == 0);
9445         e_conv = DecodeError_clone(&e_conv);
9446         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9447         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
9448         return (uint64_t)ret_conv;
9449 }
9450
9451 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
9452         if ((_res & 1) != 0) return;
9453         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
9454         FREE((void*)_res);
9455         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
9456 }
9457
9458 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
9459         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
9460         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9461         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
9462         return (uint64_t)ret_conv;
9463 }
9464
9465 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
9466         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9467         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9468         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
9469         return (uint64_t)ret_conv;
9470 }
9471
9472 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
9473         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9474         *ret_conv = CResult_NetAddressu8Z_err(e);
9475         return (uint64_t)ret_conv;
9476 }
9477
9478 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
9479         if ((_res & 1) != 0) return;
9480         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
9481         FREE((void*)_res);
9482         CResult_NetAddressu8Z_free(_res_conv);
9483 }
9484
9485 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
9486         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
9487         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9488         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
9489         return (uint64_t)ret_conv;
9490 }
9491
9492 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
9493         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
9494         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9495         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
9496         return (uint64_t)ret_conv;
9497 }
9498
9499 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
9500         LDKDecodeError e_conv;
9501         e_conv.inner = (void*)(e & (~1));
9502         e_conv.is_owned = (e & 1) || (e == 0);
9503         e_conv = DecodeError_clone(&e_conv);
9504         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9505         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
9506         return (uint64_t)ret_conv;
9507 }
9508
9509 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
9510         if ((_res & 1) != 0) return;
9511         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9512         FREE((void*)_res);
9513         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
9514 }
9515
9516 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
9517         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
9518         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9519         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
9520         return (uint64_t)ret_conv;
9521 }
9522
9523 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
9524         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9525         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9526         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
9527         return (uint64_t)ret_conv;
9528 }
9529
9530 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
9531         LDKDecodeError e_conv;
9532         e_conv.inner = (void*)(e & (~1));
9533         e_conv.is_owned = (e & 1) || (e == 0);
9534         e_conv = DecodeError_clone(&e_conv);
9535         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9536         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
9537         return (uint64_t)ret_conv;
9538 }
9539
9540 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
9541         if ((_res & 1) != 0) return;
9542         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
9543         FREE((void*)_res);
9544         CResult_NetAddressDecodeErrorZ_free(_res_conv);
9545 }
9546
9547 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
9548         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
9549         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9550         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
9551         return (uint64_t)ret_conv;
9552 }
9553
9554 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
9555         LDKCVec_UpdateAddHTLCZ _res_constr;
9556         _res_constr.datalen = *((uint32_t*)_res);
9557         if (_res_constr.datalen > 0)
9558                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
9559         else
9560                 _res_constr.data = NULL;
9561         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9562         for (size_t p = 0; p < _res_constr.datalen; p++) {
9563                 uint32_t _res_conv_15 = _res_vals[p];
9564                 LDKUpdateAddHTLC _res_conv_15_conv;
9565                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
9566                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
9567                 _res_constr.data[p] = _res_conv_15_conv;
9568         }
9569         CVec_UpdateAddHTLCZ_free(_res_constr);
9570 }
9571
9572 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
9573         LDKCVec_UpdateFulfillHTLCZ _res_constr;
9574         _res_constr.datalen = *((uint32_t*)_res);
9575         if (_res_constr.datalen > 0)
9576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
9577         else
9578                 _res_constr.data = NULL;
9579         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9580         for (size_t t = 0; t < _res_constr.datalen; t++) {
9581                 uint32_t _res_conv_19 = _res_vals[t];
9582                 LDKUpdateFulfillHTLC _res_conv_19_conv;
9583                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
9584                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
9585                 _res_constr.data[t] = _res_conv_19_conv;
9586         }
9587         CVec_UpdateFulfillHTLCZ_free(_res_constr);
9588 }
9589
9590 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
9591         LDKCVec_UpdateFailHTLCZ _res_constr;
9592         _res_constr.datalen = *((uint32_t*)_res);
9593         if (_res_constr.datalen > 0)
9594                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
9595         else
9596                 _res_constr.data = NULL;
9597         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9598         for (size_t q = 0; q < _res_constr.datalen; q++) {
9599                 uint32_t _res_conv_16 = _res_vals[q];
9600                 LDKUpdateFailHTLC _res_conv_16_conv;
9601                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9602                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9603                 _res_constr.data[q] = _res_conv_16_conv;
9604         }
9605         CVec_UpdateFailHTLCZ_free(_res_constr);
9606 }
9607
9608 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
9609         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
9610         _res_constr.datalen = *((uint32_t*)_res);
9611         if (_res_constr.datalen > 0)
9612                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
9613         else
9614                 _res_constr.data = NULL;
9615         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9616         for (size_t z = 0; z < _res_constr.datalen; z++) {
9617                 uint32_t _res_conv_25 = _res_vals[z];
9618                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9619                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9620                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9621                 _res_constr.data[z] = _res_conv_25_conv;
9622         }
9623         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9624 }
9625
9626 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
9627         LDKAcceptChannel o_conv;
9628         o_conv.inner = (void*)(o & (~1));
9629         o_conv.is_owned = (o & 1) || (o == 0);
9630         o_conv = AcceptChannel_clone(&o_conv);
9631         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9632         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9633         return (uint64_t)ret_conv;
9634 }
9635
9636 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
9637         LDKDecodeError e_conv;
9638         e_conv.inner = (void*)(e & (~1));
9639         e_conv.is_owned = (e & 1) || (e == 0);
9640         e_conv = DecodeError_clone(&e_conv);
9641         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9642         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9643         return (uint64_t)ret_conv;
9644 }
9645
9646 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
9647         if ((_res & 1) != 0) return;
9648         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9649         FREE((void*)_res);
9650         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9651 }
9652
9653 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
9654         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9655         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9656         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9657         return (uint64_t)ret_conv;
9658 }
9659
9660 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
9661         LDKAnnouncementSignatures o_conv;
9662         o_conv.inner = (void*)(o & (~1));
9663         o_conv.is_owned = (o & 1) || (o == 0);
9664         o_conv = AnnouncementSignatures_clone(&o_conv);
9665         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9666         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9667         return (uint64_t)ret_conv;
9668 }
9669
9670 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
9671         LDKDecodeError e_conv;
9672         e_conv.inner = (void*)(e & (~1));
9673         e_conv.is_owned = (e & 1) || (e == 0);
9674         e_conv = DecodeError_clone(&e_conv);
9675         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9676         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9677         return (uint64_t)ret_conv;
9678 }
9679
9680 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
9681         if ((_res & 1) != 0) return;
9682         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9683         FREE((void*)_res);
9684         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9685 }
9686
9687 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
9688         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9689         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9690         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9691         return (uint64_t)ret_conv;
9692 }
9693
9694 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
9695         LDKChannelReestablish o_conv;
9696         o_conv.inner = (void*)(o & (~1));
9697         o_conv.is_owned = (o & 1) || (o == 0);
9698         o_conv = ChannelReestablish_clone(&o_conv);
9699         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9700         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9701         return (uint64_t)ret_conv;
9702 }
9703
9704 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
9705         LDKDecodeError e_conv;
9706         e_conv.inner = (void*)(e & (~1));
9707         e_conv.is_owned = (e & 1) || (e == 0);
9708         e_conv = DecodeError_clone(&e_conv);
9709         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9710         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9711         return (uint64_t)ret_conv;
9712 }
9713
9714 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
9715         if ((_res & 1) != 0) return;
9716         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9717         FREE((void*)_res);
9718         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9719 }
9720
9721 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
9722         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9723         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9724         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9725         return (uint64_t)ret_conv;
9726 }
9727
9728 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
9729         LDKClosingSigned o_conv;
9730         o_conv.inner = (void*)(o & (~1));
9731         o_conv.is_owned = (o & 1) || (o == 0);
9732         o_conv = ClosingSigned_clone(&o_conv);
9733         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9734         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9735         return (uint64_t)ret_conv;
9736 }
9737
9738 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
9739         LDKDecodeError e_conv;
9740         e_conv.inner = (void*)(e & (~1));
9741         e_conv.is_owned = (e & 1) || (e == 0);
9742         e_conv = DecodeError_clone(&e_conv);
9743         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9744         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9745         return (uint64_t)ret_conv;
9746 }
9747
9748 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
9749         if ((_res & 1) != 0) return;
9750         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9751         FREE((void*)_res);
9752         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9753 }
9754
9755 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
9756         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9757         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9758         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9759         return (uint64_t)ret_conv;
9760 }
9761
9762 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
9763         LDKCommitmentSigned o_conv;
9764         o_conv.inner = (void*)(o & (~1));
9765         o_conv.is_owned = (o & 1) || (o == 0);
9766         o_conv = CommitmentSigned_clone(&o_conv);
9767         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9768         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
9769         return (uint64_t)ret_conv;
9770 }
9771
9772 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
9773         LDKDecodeError e_conv;
9774         e_conv.inner = (void*)(e & (~1));
9775         e_conv.is_owned = (e & 1) || (e == 0);
9776         e_conv = DecodeError_clone(&e_conv);
9777         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9778         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
9779         return (uint64_t)ret_conv;
9780 }
9781
9782 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
9783         if ((_res & 1) != 0) return;
9784         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9785         FREE((void*)_res);
9786         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
9787 }
9788
9789 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
9790         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
9791         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9792         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
9793         return (uint64_t)ret_conv;
9794 }
9795
9796 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
9797         LDKFundingCreated o_conv;
9798         o_conv.inner = (void*)(o & (~1));
9799         o_conv.is_owned = (o & 1) || (o == 0);
9800         o_conv = FundingCreated_clone(&o_conv);
9801         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9802         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
9803         return (uint64_t)ret_conv;
9804 }
9805
9806 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
9807         LDKDecodeError e_conv;
9808         e_conv.inner = (void*)(e & (~1));
9809         e_conv.is_owned = (e & 1) || (e == 0);
9810         e_conv = DecodeError_clone(&e_conv);
9811         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9812         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
9813         return (uint64_t)ret_conv;
9814 }
9815
9816 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
9817         if ((_res & 1) != 0) return;
9818         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9819         FREE((void*)_res);
9820         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
9821 }
9822
9823 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
9824         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
9825         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9826         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
9827         return (uint64_t)ret_conv;
9828 }
9829
9830 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
9831         LDKFundingSigned o_conv;
9832         o_conv.inner = (void*)(o & (~1));
9833         o_conv.is_owned = (o & 1) || (o == 0);
9834         o_conv = FundingSigned_clone(&o_conv);
9835         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9836         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
9837         return (uint64_t)ret_conv;
9838 }
9839
9840 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
9841         LDKDecodeError e_conv;
9842         e_conv.inner = (void*)(e & (~1));
9843         e_conv.is_owned = (e & 1) || (e == 0);
9844         e_conv = DecodeError_clone(&e_conv);
9845         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9846         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
9847         return (uint64_t)ret_conv;
9848 }
9849
9850 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
9851         if ((_res & 1) != 0) return;
9852         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9853         FREE((void*)_res);
9854         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9855 }
9856
9857 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
9858         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9859         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9860         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9861         return (uint64_t)ret_conv;
9862 }
9863
9864 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
9865         LDKFundingLocked o_conv;
9866         o_conv.inner = (void*)(o & (~1));
9867         o_conv.is_owned = (o & 1) || (o == 0);
9868         o_conv = FundingLocked_clone(&o_conv);
9869         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9870         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9871         return (uint64_t)ret_conv;
9872 }
9873
9874 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
9875         LDKDecodeError e_conv;
9876         e_conv.inner = (void*)(e & (~1));
9877         e_conv.is_owned = (e & 1) || (e == 0);
9878         e_conv = DecodeError_clone(&e_conv);
9879         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9880         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9881         return (uint64_t)ret_conv;
9882 }
9883
9884 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
9885         if ((_res & 1) != 0) return;
9886         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9887         FREE((void*)_res);
9888         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9889 }
9890
9891 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
9892         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9893         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9894         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9895         return (uint64_t)ret_conv;
9896 }
9897
9898 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
9899         LDKInit o_conv;
9900         o_conv.inner = (void*)(o & (~1));
9901         o_conv.is_owned = (o & 1) || (o == 0);
9902         o_conv = Init_clone(&o_conv);
9903         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9904         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9905         return (uint64_t)ret_conv;
9906 }
9907
9908 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
9909         LDKDecodeError e_conv;
9910         e_conv.inner = (void*)(e & (~1));
9911         e_conv.is_owned = (e & 1) || (e == 0);
9912         e_conv = DecodeError_clone(&e_conv);
9913         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9914         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9915         return (uint64_t)ret_conv;
9916 }
9917
9918 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
9919         if ((_res & 1) != 0) return;
9920         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9921         FREE((void*)_res);
9922         CResult_InitDecodeErrorZ_free(_res_conv);
9923 }
9924
9925 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
9926         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9927         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9928         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9929         return (uint64_t)ret_conv;
9930 }
9931
9932 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
9933         LDKOpenChannel o_conv;
9934         o_conv.inner = (void*)(o & (~1));
9935         o_conv.is_owned = (o & 1) || (o == 0);
9936         o_conv = OpenChannel_clone(&o_conv);
9937         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9938         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9939         return (uint64_t)ret_conv;
9940 }
9941
9942 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
9943         LDKDecodeError e_conv;
9944         e_conv.inner = (void*)(e & (~1));
9945         e_conv.is_owned = (e & 1) || (e == 0);
9946         e_conv = DecodeError_clone(&e_conv);
9947         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9948         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9949         return (uint64_t)ret_conv;
9950 }
9951
9952 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
9953         if ((_res & 1) != 0) return;
9954         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9955         FREE((void*)_res);
9956         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9957 }
9958
9959 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
9960         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9961         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9962         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9963         return (uint64_t)ret_conv;
9964 }
9965
9966 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
9967         LDKRevokeAndACK o_conv;
9968         o_conv.inner = (void*)(o & (~1));
9969         o_conv.is_owned = (o & 1) || (o == 0);
9970         o_conv = RevokeAndACK_clone(&o_conv);
9971         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9972         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9973         return (uint64_t)ret_conv;
9974 }
9975
9976 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
9977         LDKDecodeError e_conv;
9978         e_conv.inner = (void*)(e & (~1));
9979         e_conv.is_owned = (e & 1) || (e == 0);
9980         e_conv = DecodeError_clone(&e_conv);
9981         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9982         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9983         return (uint64_t)ret_conv;
9984 }
9985
9986 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
9987         if ((_res & 1) != 0) return;
9988         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9989         FREE((void*)_res);
9990         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9991 }
9992
9993 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
9994         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9995         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9996         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9997         return (uint64_t)ret_conv;
9998 }
9999
10000 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
10001         LDKShutdown o_conv;
10002         o_conv.inner = (void*)(o & (~1));
10003         o_conv.is_owned = (o & 1) || (o == 0);
10004         o_conv = Shutdown_clone(&o_conv);
10005         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10006         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
10007         return (uint64_t)ret_conv;
10008 }
10009
10010 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
10011         LDKDecodeError e_conv;
10012         e_conv.inner = (void*)(e & (~1));
10013         e_conv.is_owned = (e & 1) || (e == 0);
10014         e_conv = DecodeError_clone(&e_conv);
10015         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10016         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
10017         return (uint64_t)ret_conv;
10018 }
10019
10020 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
10021         if ((_res & 1) != 0) return;
10022         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
10023         FREE((void*)_res);
10024         CResult_ShutdownDecodeErrorZ_free(_res_conv);
10025 }
10026
10027 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
10028         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
10029         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
10030         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
10031         return (uint64_t)ret_conv;
10032 }
10033
10034 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
10035         LDKUpdateFailHTLC o_conv;
10036         o_conv.inner = (void*)(o & (~1));
10037         o_conv.is_owned = (o & 1) || (o == 0);
10038         o_conv = UpdateFailHTLC_clone(&o_conv);
10039         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10040         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
10041         return (uint64_t)ret_conv;
10042 }
10043
10044 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
10045         LDKDecodeError e_conv;
10046         e_conv.inner = (void*)(e & (~1));
10047         e_conv.is_owned = (e & 1) || (e == 0);
10048         e_conv = DecodeError_clone(&e_conv);
10049         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10050         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
10051         return (uint64_t)ret_conv;
10052 }
10053
10054 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
10055         if ((_res & 1) != 0) return;
10056         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10057         FREE((void*)_res);
10058         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
10059 }
10060
10061 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
10062         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
10063         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10064         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
10065         return (uint64_t)ret_conv;
10066 }
10067
10068 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
10069         LDKUpdateFailMalformedHTLC o_conv;
10070         o_conv.inner = (void*)(o & (~1));
10071         o_conv.is_owned = (o & 1) || (o == 0);
10072         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
10073         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10074         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
10075         return (uint64_t)ret_conv;
10076 }
10077
10078 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
10079         LDKDecodeError e_conv;
10080         e_conv.inner = (void*)(e & (~1));
10081         e_conv.is_owned = (e & 1) || (e == 0);
10082         e_conv = DecodeError_clone(&e_conv);
10083         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10084         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
10085         return (uint64_t)ret_conv;
10086 }
10087
10088 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
10089         if ((_res & 1) != 0) return;
10090         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10091         FREE((void*)_res);
10092         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
10093 }
10094
10095 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
10096         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
10097         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10098         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
10099         return (uint64_t)ret_conv;
10100 }
10101
10102 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
10103         LDKUpdateFee o_conv;
10104         o_conv.inner = (void*)(o & (~1));
10105         o_conv.is_owned = (o & 1) || (o == 0);
10106         o_conv = UpdateFee_clone(&o_conv);
10107         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10108         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
10109         return (uint64_t)ret_conv;
10110 }
10111
10112 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
10113         LDKDecodeError e_conv;
10114         e_conv.inner = (void*)(e & (~1));
10115         e_conv.is_owned = (e & 1) || (e == 0);
10116         e_conv = DecodeError_clone(&e_conv);
10117         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10118         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
10119         return (uint64_t)ret_conv;
10120 }
10121
10122 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
10123         if ((_res & 1) != 0) return;
10124         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10125         FREE((void*)_res);
10126         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
10127 }
10128
10129 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
10130         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
10131         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10132         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
10133         return (uint64_t)ret_conv;
10134 }
10135
10136 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
10137         LDKUpdateFulfillHTLC o_conv;
10138         o_conv.inner = (void*)(o & (~1));
10139         o_conv.is_owned = (o & 1) || (o == 0);
10140         o_conv = UpdateFulfillHTLC_clone(&o_conv);
10141         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10142         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
10143         return (uint64_t)ret_conv;
10144 }
10145
10146 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
10147         LDKDecodeError e_conv;
10148         e_conv.inner = (void*)(e & (~1));
10149         e_conv.is_owned = (e & 1) || (e == 0);
10150         e_conv = DecodeError_clone(&e_conv);
10151         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10152         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
10153         return (uint64_t)ret_conv;
10154 }
10155
10156 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
10157         if ((_res & 1) != 0) return;
10158         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10159         FREE((void*)_res);
10160         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
10161 }
10162
10163 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
10164         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
10165         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10166         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
10167         return (uint64_t)ret_conv;
10168 }
10169
10170 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
10171         LDKUpdateAddHTLC o_conv;
10172         o_conv.inner = (void*)(o & (~1));
10173         o_conv.is_owned = (o & 1) || (o == 0);
10174         o_conv = UpdateAddHTLC_clone(&o_conv);
10175         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10176         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
10177         return (uint64_t)ret_conv;
10178 }
10179
10180 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
10181         LDKDecodeError e_conv;
10182         e_conv.inner = (void*)(e & (~1));
10183         e_conv.is_owned = (e & 1) || (e == 0);
10184         e_conv = DecodeError_clone(&e_conv);
10185         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10186         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
10187         return (uint64_t)ret_conv;
10188 }
10189
10190 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
10191         if ((_res & 1) != 0) return;
10192         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10193         FREE((void*)_res);
10194         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
10195 }
10196
10197 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
10198         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
10199         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10200         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
10201         return (uint64_t)ret_conv;
10202 }
10203
10204 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
10205         LDKPing o_conv;
10206         o_conv.inner = (void*)(o & (~1));
10207         o_conv.is_owned = (o & 1) || (o == 0);
10208         o_conv = Ping_clone(&o_conv);
10209         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10210         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
10211         return (uint64_t)ret_conv;
10212 }
10213
10214 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
10215         LDKDecodeError e_conv;
10216         e_conv.inner = (void*)(e & (~1));
10217         e_conv.is_owned = (e & 1) || (e == 0);
10218         e_conv = DecodeError_clone(&e_conv);
10219         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10220         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
10221         return (uint64_t)ret_conv;
10222 }
10223
10224 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
10225         if ((_res & 1) != 0) return;
10226         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
10227         FREE((void*)_res);
10228         CResult_PingDecodeErrorZ_free(_res_conv);
10229 }
10230
10231 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
10232         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
10233         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10234         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
10235         return (uint64_t)ret_conv;
10236 }
10237
10238 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
10239         LDKPong o_conv;
10240         o_conv.inner = (void*)(o & (~1));
10241         o_conv.is_owned = (o & 1) || (o == 0);
10242         o_conv = Pong_clone(&o_conv);
10243         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10244         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
10245         return (uint64_t)ret_conv;
10246 }
10247
10248 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
10249         LDKDecodeError e_conv;
10250         e_conv.inner = (void*)(e & (~1));
10251         e_conv.is_owned = (e & 1) || (e == 0);
10252         e_conv = DecodeError_clone(&e_conv);
10253         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10254         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
10255         return (uint64_t)ret_conv;
10256 }
10257
10258 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
10259         if ((_res & 1) != 0) return;
10260         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
10261         FREE((void*)_res);
10262         CResult_PongDecodeErrorZ_free(_res_conv);
10263 }
10264
10265 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
10266         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
10267         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10268         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
10269         return (uint64_t)ret_conv;
10270 }
10271
10272 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10273         LDKUnsignedChannelAnnouncement o_conv;
10274         o_conv.inner = (void*)(o & (~1));
10275         o_conv.is_owned = (o & 1) || (o == 0);
10276         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
10277         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10278         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
10279         return (uint64_t)ret_conv;
10280 }
10281
10282 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10283         LDKDecodeError e_conv;
10284         e_conv.inner = (void*)(e & (~1));
10285         e_conv.is_owned = (e & 1) || (e == 0);
10286         e_conv = DecodeError_clone(&e_conv);
10287         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10288         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
10289         return (uint64_t)ret_conv;
10290 }
10291
10292 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10293         if ((_res & 1) != 0) return;
10294         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10295         FREE((void*)_res);
10296         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
10297 }
10298
10299 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10300         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10301         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10302         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10303         return (uint64_t)ret_conv;
10304 }
10305
10306 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10307         LDKChannelAnnouncement o_conv;
10308         o_conv.inner = (void*)(o & (~1));
10309         o_conv.is_owned = (o & 1) || (o == 0);
10310         o_conv = ChannelAnnouncement_clone(&o_conv);
10311         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10312         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
10313         return (uint64_t)ret_conv;
10314 }
10315
10316 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10317         LDKDecodeError e_conv;
10318         e_conv.inner = (void*)(e & (~1));
10319         e_conv.is_owned = (e & 1) || (e == 0);
10320         e_conv = DecodeError_clone(&e_conv);
10321         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10322         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
10323         return (uint64_t)ret_conv;
10324 }
10325
10326 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10327         if ((_res & 1) != 0) return;
10328         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10329         FREE((void*)_res);
10330         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
10331 }
10332
10333 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10334         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10335         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10336         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10337         return (uint64_t)ret_conv;
10338 }
10339
10340 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10341         LDKUnsignedChannelUpdate o_conv;
10342         o_conv.inner = (void*)(o & (~1));
10343         o_conv.is_owned = (o & 1) || (o == 0);
10344         o_conv = UnsignedChannelUpdate_clone(&o_conv);
10345         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10346         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
10347         return (uint64_t)ret_conv;
10348 }
10349
10350 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
10351         LDKDecodeError e_conv;
10352         e_conv.inner = (void*)(e & (~1));
10353         e_conv.is_owned = (e & 1) || (e == 0);
10354         e_conv = DecodeError_clone(&e_conv);
10355         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10356         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
10357         return (uint64_t)ret_conv;
10358 }
10359
10360 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10361         if ((_res & 1) != 0) return;
10362         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10363         FREE((void*)_res);
10364         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
10365 }
10366
10367 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10368         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
10369         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10370         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
10371         return (uint64_t)ret_conv;
10372 }
10373
10374 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10375         LDKChannelUpdate o_conv;
10376         o_conv.inner = (void*)(o & (~1));
10377         o_conv.is_owned = (o & 1) || (o == 0);
10378         o_conv = ChannelUpdate_clone(&o_conv);
10379         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10380         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
10381         return (uint64_t)ret_conv;
10382 }
10383
10384 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
10385         LDKDecodeError e_conv;
10386         e_conv.inner = (void*)(e & (~1));
10387         e_conv.is_owned = (e & 1) || (e == 0);
10388         e_conv = DecodeError_clone(&e_conv);
10389         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10390         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
10391         return (uint64_t)ret_conv;
10392 }
10393
10394 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10395         if ((_res & 1) != 0) return;
10396         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10397         FREE((void*)_res);
10398         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
10399 }
10400
10401 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10402         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
10403         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10404         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
10405         return (uint64_t)ret_conv;
10406 }
10407
10408 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
10409         LDKErrorMessage o_conv;
10410         o_conv.inner = (void*)(o & (~1));
10411         o_conv.is_owned = (o & 1) || (o == 0);
10412         o_conv = ErrorMessage_clone(&o_conv);
10413         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10414         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
10415         return (uint64_t)ret_conv;
10416 }
10417
10418 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
10419         LDKDecodeError e_conv;
10420         e_conv.inner = (void*)(e & (~1));
10421         e_conv.is_owned = (e & 1) || (e == 0);
10422         e_conv = DecodeError_clone(&e_conv);
10423         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10424         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
10425         return (uint64_t)ret_conv;
10426 }
10427
10428 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
10429         if ((_res & 1) != 0) return;
10430         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
10431         FREE((void*)_res);
10432         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
10433 }
10434
10435 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
10436         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
10437         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10438         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
10439         return (uint64_t)ret_conv;
10440 }
10441
10442 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10443         LDKUnsignedNodeAnnouncement o_conv;
10444         o_conv.inner = (void*)(o & (~1));
10445         o_conv.is_owned = (o & 1) || (o == 0);
10446         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
10447         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10448         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
10449         return (uint64_t)ret_conv;
10450 }
10451
10452 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10453         LDKDecodeError e_conv;
10454         e_conv.inner = (void*)(e & (~1));
10455         e_conv.is_owned = (e & 1) || (e == 0);
10456         e_conv = DecodeError_clone(&e_conv);
10457         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10458         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
10459         return (uint64_t)ret_conv;
10460 }
10461
10462 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10463         if ((_res & 1) != 0) return;
10464         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10465         FREE((void*)_res);
10466         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
10467 }
10468
10469 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10470         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
10471         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10472         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
10473         return (uint64_t)ret_conv;
10474 }
10475
10476 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10477         LDKNodeAnnouncement o_conv;
10478         o_conv.inner = (void*)(o & (~1));
10479         o_conv.is_owned = (o & 1) || (o == 0);
10480         o_conv = NodeAnnouncement_clone(&o_conv);
10481         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10482         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
10483         return (uint64_t)ret_conv;
10484 }
10485
10486 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10487         LDKDecodeError e_conv;
10488         e_conv.inner = (void*)(e & (~1));
10489         e_conv.is_owned = (e & 1) || (e == 0);
10490         e_conv = DecodeError_clone(&e_conv);
10491         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10492         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
10493         return (uint64_t)ret_conv;
10494 }
10495
10496 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10497         if ((_res & 1) != 0) return;
10498         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10499         FREE((void*)_res);
10500         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
10501 }
10502
10503 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10504         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
10505         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10506         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
10507         return (uint64_t)ret_conv;
10508 }
10509
10510 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
10511         LDKQueryShortChannelIds o_conv;
10512         o_conv.inner = (void*)(o & (~1));
10513         o_conv.is_owned = (o & 1) || (o == 0);
10514         o_conv = QueryShortChannelIds_clone(&o_conv);
10515         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10516         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
10517         return (uint64_t)ret_conv;
10518 }
10519
10520 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
10521         LDKDecodeError e_conv;
10522         e_conv.inner = (void*)(e & (~1));
10523         e_conv.is_owned = (e & 1) || (e == 0);
10524         e_conv = DecodeError_clone(&e_conv);
10525         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10526         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
10527         return (uint64_t)ret_conv;
10528 }
10529
10530 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
10531         if ((_res & 1) != 0) return;
10532         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
10533         FREE((void*)_res);
10534         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
10535 }
10536
10537 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
10538         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
10539         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10540         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
10541         return (uint64_t)ret_conv;
10542 }
10543
10544 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
10545         LDKReplyShortChannelIdsEnd o_conv;
10546         o_conv.inner = (void*)(o & (~1));
10547         o_conv.is_owned = (o & 1) || (o == 0);
10548         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
10549         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10550         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
10551         return (uint64_t)ret_conv;
10552 }
10553
10554 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
10555         LDKDecodeError e_conv;
10556         e_conv.inner = (void*)(e & (~1));
10557         e_conv.is_owned = (e & 1) || (e == 0);
10558         e_conv = DecodeError_clone(&e_conv);
10559         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10560         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
10561         return (uint64_t)ret_conv;
10562 }
10563
10564 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
10565         if ((_res & 1) != 0) return;
10566         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
10567         FREE((void*)_res);
10568         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
10569 }
10570
10571 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
10572         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
10573         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10574         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
10575         return (uint64_t)ret_conv;
10576 }
10577
10578 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
10579         LDKQueryChannelRange o_conv;
10580         o_conv.inner = (void*)(o & (~1));
10581         o_conv.is_owned = (o & 1) || (o == 0);
10582         o_conv = QueryChannelRange_clone(&o_conv);
10583         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10584         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
10585         return (uint64_t)ret_conv;
10586 }
10587
10588 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
10589         LDKDecodeError e_conv;
10590         e_conv.inner = (void*)(e & (~1));
10591         e_conv.is_owned = (e & 1) || (e == 0);
10592         e_conv = DecodeError_clone(&e_conv);
10593         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10594         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
10595         return (uint64_t)ret_conv;
10596 }
10597
10598 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
10599         if ((_res & 1) != 0) return;
10600         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10601         FREE((void*)_res);
10602         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
10603 }
10604
10605 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10606         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
10607         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10608         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
10609         return (uint64_t)ret_conv;
10610 }
10611
10612 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
10613         LDKReplyChannelRange o_conv;
10614         o_conv.inner = (void*)(o & (~1));
10615         o_conv.is_owned = (o & 1) || (o == 0);
10616         o_conv = ReplyChannelRange_clone(&o_conv);
10617         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10618         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10619         return (uint64_t)ret_conv;
10620 }
10621
10622 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
10623         LDKDecodeError e_conv;
10624         e_conv.inner = (void*)(e & (~1));
10625         e_conv.is_owned = (e & 1) || (e == 0);
10626         e_conv = DecodeError_clone(&e_conv);
10627         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10628         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10629         return (uint64_t)ret_conv;
10630 }
10631
10632 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
10633         if ((_res & 1) != 0) return;
10634         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10635         FREE((void*)_res);
10636         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10637 }
10638
10639 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10640         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10641         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10642         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10643         return (uint64_t)ret_conv;
10644 }
10645
10646 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
10647         LDKGossipTimestampFilter o_conv;
10648         o_conv.inner = (void*)(o & (~1));
10649         o_conv.is_owned = (o & 1) || (o == 0);
10650         o_conv = GossipTimestampFilter_clone(&o_conv);
10651         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10652         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10653         return (uint64_t)ret_conv;
10654 }
10655
10656 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
10657         LDKDecodeError e_conv;
10658         e_conv.inner = (void*)(e & (~1));
10659         e_conv.is_owned = (e & 1) || (e == 0);
10660         e_conv = DecodeError_clone(&e_conv);
10661         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10662         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10663         return (uint64_t)ret_conv;
10664 }
10665
10666 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
10667         if ((_res & 1) != 0) return;
10668         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10669         FREE((void*)_res);
10670         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10671 }
10672
10673 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
10674         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10675         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10676         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10677         return (uint64_t)ret_conv;
10678 }
10679
10680 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
10681         LDKInvoice o_conv;
10682         o_conv.inner = (void*)(o & (~1));
10683         o_conv.is_owned = (o & 1) || (o == 0);
10684         o_conv = Invoice_clone(&o_conv);
10685         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10686         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
10687         return (uint64_t)ret_conv;
10688 }
10689
10690 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
10691         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
10692         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10693         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
10694         return (uint64_t)ret_conv;
10695 }
10696
10697 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
10698         if ((_res & 1) != 0) return;
10699         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
10700         FREE((void*)_res);
10701         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
10702 }
10703
10704 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
10705         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
10706         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10707         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
10708         return (uint64_t)ret_conv;
10709 }
10710
10711 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
10712         if ((this_ptr & 1) != 0) return;
10713         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10714         FREE((void*)this_ptr);
10715         Event_free(this_ptr_conv);
10716 }
10717
10718 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
10719         LDKEvent* orig_conv = (LDKEvent*)orig;
10720         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10721         *ret_copy = Event_clone(orig_conv);
10722         uint64_t ret_ref = (uint64_t)ret_copy;
10723         return ret_ref;
10724 }
10725
10726 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
10727         LDKEvent* obj_conv = (LDKEvent*)obj;
10728         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10729         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10730         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10731         CVec_u8Z_free(ret_var);
10732         return ret_arr;
10733 }
10734
10735 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
10736         if ((this_ptr & 1) != 0) return;
10737         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10738         FREE((void*)this_ptr);
10739         MessageSendEvent_free(this_ptr_conv);
10740 }
10741
10742 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
10743         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10744         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10745         *ret_copy = MessageSendEvent_clone(orig_conv);
10746         uint64_t ret_ref = (uint64_t)ret_copy;
10747         return ret_ref;
10748 }
10749
10750 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
10751         if ((this_ptr & 1) != 0) return;
10752         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10753         FREE((void*)this_ptr);
10754         MessageSendEventsProvider_free(this_ptr_conv);
10755 }
10756
10757 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
10758         if ((this_ptr & 1) != 0) return;
10759         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10760         FREE((void*)this_ptr);
10761         EventsProvider_free(this_ptr_conv);
10762 }
10763
10764 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
10765         if ((this_ptr & 1) != 0) return;
10766         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
10767         FREE((void*)this_ptr);
10768         EventHandler_free(this_ptr_conv);
10769 }
10770
10771 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
10772         if ((this_ptr & 1) != 0) return;
10773         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10774         FREE((void*)this_ptr);
10775         APIError_free(this_ptr_conv);
10776 }
10777
10778 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
10779         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10780         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10781         *ret_copy = APIError_clone(orig_conv);
10782         uint64_t ret_ref = (uint64_t)ret_copy;
10783         return ret_ref;
10784 }
10785
10786 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
10787         LDKu8slice msg_ref;
10788         msg_ref.datalen = *((uint32_t*)msg);
10789         msg_ref.data = (int8_t*)(msg + 4);
10790         unsigned char sk_arr[32];
10791         CHECK(*((uint32_t*)sk) == 32);
10792         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
10793         unsigned char (*sk_ref)[32] = &sk_arr;
10794         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10795         *ret_conv = sign(msg_ref, sk_ref);
10796         return (uint64_t)ret_conv;
10797 }
10798
10799 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
10800         LDKu8slice msg_ref;
10801         msg_ref.datalen = *((uint32_t*)msg);
10802         msg_ref.data = (int8_t*)(msg + 4);
10803         LDKStr sig_conv = str_ref_to_owned_c(sig);
10804         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10805         *ret_conv = recover_pk(msg_ref, sig_conv);
10806         return (uint64_t)ret_conv;
10807 }
10808
10809 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
10810         LDKu8slice msg_ref;
10811         msg_ref.datalen = *((uint32_t*)msg);
10812         msg_ref.data = (int8_t*)(msg + 4);
10813         LDKStr sig_conv = str_ref_to_owned_c(sig);
10814         LDKPublicKey pk_ref;
10815         CHECK(*((uint32_t*)pk) == 33);
10816         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
10817         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
10818         return ret_val;
10819 }
10820
10821 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
10822         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10823         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
10824         return ret_conv;
10825 }
10826
10827 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
10828         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
10829         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
10830         jboolean ret_val = Level_eq(a_conv, b_conv);
10831         return ret_val;
10832 }
10833
10834 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
10835         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
10836         int64_t ret_val = Level_hash(o_conv);
10837         return ret_val;
10838 }
10839
10840 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
10841         uint32_t ret_conv = LDKLevel_to_js(Level_max());
10842         return ret_conv;
10843 }
10844
10845 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
10846         if ((this_ptr & 1) != 0) return;
10847         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10848         FREE((void*)this_ptr);
10849         Logger_free(this_ptr_conv);
10850 }
10851
10852 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
10853         LDKChannelHandshakeConfig this_obj_conv;
10854         this_obj_conv.inner = (void*)(this_obj & (~1));
10855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10856         ChannelHandshakeConfig_free(this_obj_conv);
10857 }
10858
10859 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
10860         LDKChannelHandshakeConfig this_ptr_conv;
10861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10862         this_ptr_conv.is_owned = false;
10863         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10864         return ret_val;
10865 }
10866
10867 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
10868         LDKChannelHandshakeConfig this_ptr_conv;
10869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10870         this_ptr_conv.is_owned = false;
10871         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10872 }
10873
10874 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
10875         LDKChannelHandshakeConfig this_ptr_conv;
10876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10877         this_ptr_conv.is_owned = false;
10878         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10879         return ret_val;
10880 }
10881
10882 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
10883         LDKChannelHandshakeConfig this_ptr_conv;
10884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10885         this_ptr_conv.is_owned = false;
10886         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10887 }
10888
10889 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
10890         LDKChannelHandshakeConfig this_ptr_conv;
10891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10892         this_ptr_conv.is_owned = false;
10893         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10894         return ret_val;
10895 }
10896
10897 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10898         LDKChannelHandshakeConfig this_ptr_conv;
10899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10900         this_ptr_conv.is_owned = false;
10901         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10902 }
10903
10904 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) {
10905         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10908         uint64_t ret_ref = (uint64_t)ret_var.inner;
10909         if (ret_var.is_owned) {
10910                 ret_ref |= 1;
10911         }
10912         return ret_ref;
10913 }
10914
10915 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
10916         LDKChannelHandshakeConfig orig_conv;
10917         orig_conv.inner = (void*)(orig & (~1));
10918         orig_conv.is_owned = false;
10919         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10922         uint64_t ret_ref = (uint64_t)ret_var.inner;
10923         if (ret_var.is_owned) {
10924                 ret_ref |= 1;
10925         }
10926         return ret_ref;
10927 }
10928
10929 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
10930         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10933         uint64_t ret_ref = (uint64_t)ret_var.inner;
10934         if (ret_var.is_owned) {
10935                 ret_ref |= 1;
10936         }
10937         return ret_ref;
10938 }
10939
10940 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
10941         LDKChannelHandshakeLimits this_obj_conv;
10942         this_obj_conv.inner = (void*)(this_obj & (~1));
10943         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10944         ChannelHandshakeLimits_free(this_obj_conv);
10945 }
10946
10947 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
10948         LDKChannelHandshakeLimits this_ptr_conv;
10949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10950         this_ptr_conv.is_owned = false;
10951         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10952         return ret_val;
10953 }
10954
10955 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
10956         LDKChannelHandshakeLimits this_ptr_conv;
10957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10958         this_ptr_conv.is_owned = false;
10959         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10960 }
10961
10962 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
10963         LDKChannelHandshakeLimits this_ptr_conv;
10964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10965         this_ptr_conv.is_owned = false;
10966         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10967         return ret_val;
10968 }
10969
10970 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10971         LDKChannelHandshakeLimits this_ptr_conv;
10972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10973         this_ptr_conv.is_owned = false;
10974         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10975 }
10976
10977 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
10978         LDKChannelHandshakeLimits this_ptr_conv;
10979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10980         this_ptr_conv.is_owned = false;
10981         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10982         return ret_val;
10983 }
10984
10985 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
10986         LDKChannelHandshakeLimits this_ptr_conv;
10987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10988         this_ptr_conv.is_owned = false;
10989         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10990 }
10991
10992 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
10993         LDKChannelHandshakeLimits this_ptr_conv;
10994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10995         this_ptr_conv.is_owned = false;
10996         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10997         return ret_val;
10998 }
10999
11000 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11001         LDKChannelHandshakeLimits this_ptr_conv;
11002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11003         this_ptr_conv.is_owned = false;
11004         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
11005 }
11006
11007 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
11008         LDKChannelHandshakeLimits this_ptr_conv;
11009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11010         this_ptr_conv.is_owned = false;
11011         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
11012         return ret_val;
11013 }
11014
11015 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
11016         LDKChannelHandshakeLimits this_ptr_conv;
11017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11018         this_ptr_conv.is_owned = false;
11019         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
11020 }
11021
11022 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
11023         LDKChannelHandshakeLimits this_ptr_conv;
11024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11025         this_ptr_conv.is_owned = false;
11026         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
11027         return ret_val;
11028 }
11029
11030 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
11031         LDKChannelHandshakeLimits this_ptr_conv;
11032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11033         this_ptr_conv.is_owned = false;
11034         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
11035 }
11036
11037 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
11038         LDKChannelHandshakeLimits this_ptr_conv;
11039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11040         this_ptr_conv.is_owned = false;
11041         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
11042         return ret_val;
11043 }
11044
11045 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
11046         LDKChannelHandshakeLimits this_ptr_conv;
11047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11048         this_ptr_conv.is_owned = false;
11049         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
11050 }
11051
11052 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
11053         LDKChannelHandshakeLimits this_ptr_conv;
11054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11055         this_ptr_conv.is_owned = false;
11056         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
11057         return ret_val;
11058 }
11059
11060 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
11061         LDKChannelHandshakeLimits this_ptr_conv;
11062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11063         this_ptr_conv.is_owned = false;
11064         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
11065 }
11066
11067 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, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
11068         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, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
11069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11071         uint64_t ret_ref = (uint64_t)ret_var.inner;
11072         if (ret_var.is_owned) {
11073                 ret_ref |= 1;
11074         }
11075         return ret_ref;
11076 }
11077
11078 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
11079         LDKChannelHandshakeLimits orig_conv;
11080         orig_conv.inner = (void*)(orig & (~1));
11081         orig_conv.is_owned = false;
11082         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
11083         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11084         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11085         uint64_t ret_ref = (uint64_t)ret_var.inner;
11086         if (ret_var.is_owned) {
11087                 ret_ref |= 1;
11088         }
11089         return ret_ref;
11090 }
11091
11092 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
11093         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
11094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11096         uint64_t ret_ref = (uint64_t)ret_var.inner;
11097         if (ret_var.is_owned) {
11098                 ret_ref |= 1;
11099         }
11100         return ret_ref;
11101 }
11102
11103 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
11104         LDKChannelConfig this_obj_conv;
11105         this_obj_conv.inner = (void*)(this_obj & (~1));
11106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11107         ChannelConfig_free(this_obj_conv);
11108 }
11109
11110 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
11111         LDKChannelConfig this_ptr_conv;
11112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11113         this_ptr_conv.is_owned = false;
11114         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
11115         return ret_val;
11116 }
11117
11118 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11119         LDKChannelConfig this_ptr_conv;
11120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11121         this_ptr_conv.is_owned = false;
11122         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
11123 }
11124
11125 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
11126         LDKChannelConfig this_ptr_conv;
11127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11128         this_ptr_conv.is_owned = false;
11129         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
11130         return ret_val;
11131 }
11132
11133 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
11134         LDKChannelConfig this_ptr_conv;
11135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11136         this_ptr_conv.is_owned = false;
11137         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
11138 }
11139
11140 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
11141         LDKChannelConfig this_ptr_conv;
11142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11143         this_ptr_conv.is_owned = false;
11144         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
11145         return ret_val;
11146 }
11147
11148 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11149         LDKChannelConfig this_ptr_conv;
11150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11151         this_ptr_conv.is_owned = false;
11152         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
11153 }
11154
11155 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
11156         LDKChannelConfig this_ptr_conv;
11157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11158         this_ptr_conv.is_owned = false;
11159         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
11160         return ret_val;
11161 }
11162
11163 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
11164         LDKChannelConfig this_ptr_conv;
11165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11166         this_ptr_conv.is_owned = false;
11167         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
11168 }
11169
11170 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
11171         LDKChannelConfig this_ptr_conv;
11172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11173         this_ptr_conv.is_owned = false;
11174         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
11175         return ret_val;
11176 }
11177
11178 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
11179         LDKChannelConfig this_ptr_conv;
11180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11181         this_ptr_conv.is_owned = false;
11182         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
11183 }
11184
11185 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
11186         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
11187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11189         uint64_t ret_ref = (uint64_t)ret_var.inner;
11190         if (ret_var.is_owned) {
11191                 ret_ref |= 1;
11192         }
11193         return ret_ref;
11194 }
11195
11196 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
11197         LDKChannelConfig orig_conv;
11198         orig_conv.inner = (void*)(orig & (~1));
11199         orig_conv.is_owned = false;
11200         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
11201         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11202         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11203         uint64_t ret_ref = (uint64_t)ret_var.inner;
11204         if (ret_var.is_owned) {
11205                 ret_ref |= 1;
11206         }
11207         return ret_ref;
11208 }
11209
11210 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
11211         LDKChannelConfig ret_var = ChannelConfig_default();
11212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11214         uint64_t ret_ref = (uint64_t)ret_var.inner;
11215         if (ret_var.is_owned) {
11216                 ret_ref |= 1;
11217         }
11218         return ret_ref;
11219 }
11220
11221 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
11222         LDKChannelConfig obj_conv;
11223         obj_conv.inner = (void*)(obj & (~1));
11224         obj_conv.is_owned = false;
11225         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
11226         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11227         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11228         CVec_u8Z_free(ret_var);
11229         return ret_arr;
11230 }
11231
11232 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
11233         LDKu8slice ser_ref;
11234         ser_ref.datalen = *((uint32_t*)ser);
11235         ser_ref.data = (int8_t*)(ser + 4);
11236         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11237         *ret_conv = ChannelConfig_read(ser_ref);
11238         return (uint64_t)ret_conv;
11239 }
11240
11241 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
11242         LDKUserConfig this_obj_conv;
11243         this_obj_conv.inner = (void*)(this_obj & (~1));
11244         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11245         UserConfig_free(this_obj_conv);
11246 }
11247
11248 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
11249         LDKUserConfig this_ptr_conv;
11250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11251         this_ptr_conv.is_owned = false;
11252         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
11253         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11254         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11255         uint64_t ret_ref = (uint64_t)ret_var.inner;
11256         if (ret_var.is_owned) {
11257                 ret_ref |= 1;
11258         }
11259         return ret_ref;
11260 }
11261
11262 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
11263         LDKUserConfig this_ptr_conv;
11264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11265         this_ptr_conv.is_owned = false;
11266         LDKChannelHandshakeConfig val_conv;
11267         val_conv.inner = (void*)(val & (~1));
11268         val_conv.is_owned = (val & 1) || (val == 0);
11269         val_conv = ChannelHandshakeConfig_clone(&val_conv);
11270         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
11271 }
11272
11273 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
11274         LDKUserConfig this_ptr_conv;
11275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11276         this_ptr_conv.is_owned = false;
11277         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
11278         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11279         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11280         uint64_t ret_ref = (uint64_t)ret_var.inner;
11281         if (ret_var.is_owned) {
11282                 ret_ref |= 1;
11283         }
11284         return ret_ref;
11285 }
11286
11287 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
11288         LDKUserConfig this_ptr_conv;
11289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11290         this_ptr_conv.is_owned = false;
11291         LDKChannelHandshakeLimits val_conv;
11292         val_conv.inner = (void*)(val & (~1));
11293         val_conv.is_owned = (val & 1) || (val == 0);
11294         val_conv = ChannelHandshakeLimits_clone(&val_conv);
11295         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
11296 }
11297
11298 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
11299         LDKUserConfig this_ptr_conv;
11300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11301         this_ptr_conv.is_owned = false;
11302         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
11303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11305         uint64_t ret_ref = (uint64_t)ret_var.inner;
11306         if (ret_var.is_owned) {
11307                 ret_ref |= 1;
11308         }
11309         return ret_ref;
11310 }
11311
11312 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
11313         LDKUserConfig this_ptr_conv;
11314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11315         this_ptr_conv.is_owned = false;
11316         LDKChannelConfig val_conv;
11317         val_conv.inner = (void*)(val & (~1));
11318         val_conv.is_owned = (val & 1) || (val == 0);
11319         val_conv = ChannelConfig_clone(&val_conv);
11320         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
11321 }
11322
11323 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
11324         LDKUserConfig this_ptr_conv;
11325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11326         this_ptr_conv.is_owned = false;
11327         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
11328         return ret_val;
11329 }
11330
11331 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
11332         LDKUserConfig this_ptr_conv;
11333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11334         this_ptr_conv.is_owned = false;
11335         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
11336 }
11337
11338 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, jboolean accept_forwards_to_priv_channels_arg) {
11339         LDKChannelHandshakeConfig own_channel_config_arg_conv;
11340         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
11341         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
11342         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
11343         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
11344         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
11345         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
11346         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
11347         LDKChannelConfig channel_options_arg_conv;
11348         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
11349         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
11350         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
11351         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
11352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11354         uint64_t ret_ref = (uint64_t)ret_var.inner;
11355         if (ret_var.is_owned) {
11356                 ret_ref |= 1;
11357         }
11358         return ret_ref;
11359 }
11360
11361 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
11362         LDKUserConfig orig_conv;
11363         orig_conv.inner = (void*)(orig & (~1));
11364         orig_conv.is_owned = false;
11365         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
11366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11368         uint64_t ret_ref = (uint64_t)ret_var.inner;
11369         if (ret_var.is_owned) {
11370                 ret_ref |= 1;
11371         }
11372         return ret_ref;
11373 }
11374
11375 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
11376         LDKUserConfig ret_var = UserConfig_default();
11377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11379         uint64_t ret_ref = (uint64_t)ret_var.inner;
11380         if (ret_var.is_owned) {
11381                 ret_ref |= 1;
11382         }
11383         return ret_ref;
11384 }
11385
11386 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
11387         LDKBestBlock this_obj_conv;
11388         this_obj_conv.inner = (void*)(this_obj & (~1));
11389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11390         BestBlock_free(this_obj_conv);
11391 }
11392
11393 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
11394         LDKBestBlock orig_conv;
11395         orig_conv.inner = (void*)(orig & (~1));
11396         orig_conv.is_owned = false;
11397         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
11398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11400         uint64_t ret_ref = (uint64_t)ret_var.inner;
11401         if (ret_var.is_owned) {
11402                 ret_ref |= 1;
11403         }
11404         return ret_ref;
11405 }
11406
11407 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
11408         LDKNetwork network_conv = LDKNetwork_from_js(network);
11409         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
11410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11412         uint64_t ret_ref = (uint64_t)ret_var.inner;
11413         if (ret_var.is_owned) {
11414                 ret_ref |= 1;
11415         }
11416         return ret_ref;
11417 }
11418
11419 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
11420         LDKThirtyTwoBytes block_hash_ref;
11421         CHECK(*((uint32_t*)block_hash) == 32);
11422         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
11423         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
11424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11426         uint64_t ret_ref = (uint64_t)ret_var.inner;
11427         if (ret_var.is_owned) {
11428                 ret_ref |= 1;
11429         }
11430         return ret_ref;
11431 }
11432
11433 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
11434         LDKBestBlock this_arg_conv;
11435         this_arg_conv.inner = (void*)(this_arg & (~1));
11436         this_arg_conv.is_owned = false;
11437         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11438         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
11439         return ret_arr;
11440 }
11441
11442 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
11443         LDKBestBlock this_arg_conv;
11444         this_arg_conv.inner = (void*)(this_arg & (~1));
11445         this_arg_conv.is_owned = false;
11446         int32_t ret_val = BestBlock_height(&this_arg_conv);
11447         return ret_val;
11448 }
11449
11450 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
11451         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
11452         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
11453         return ret_conv;
11454 }
11455
11456 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
11457         if ((this_ptr & 1) != 0) return;
11458         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
11459         FREE((void*)this_ptr);
11460         Access_free(this_ptr_conv);
11461 }
11462
11463 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
11464         if ((this_ptr & 1) != 0) return;
11465         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
11466         FREE((void*)this_ptr);
11467         Listen_free(this_ptr_conv);
11468 }
11469
11470 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
11471         if ((this_ptr & 1) != 0) return;
11472         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
11473         FREE((void*)this_ptr);
11474         Confirm_free(this_ptr_conv);
11475 }
11476
11477 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
11478         if ((this_ptr & 1) != 0) return;
11479         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
11480         FREE((void*)this_ptr);
11481         Watch_free(this_ptr_conv);
11482 }
11483
11484 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
11485         if ((this_ptr & 1) != 0) return;
11486         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
11487         FREE((void*)this_ptr);
11488         Filter_free(this_ptr_conv);
11489 }
11490
11491 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
11492         LDKWatchedOutput this_obj_conv;
11493         this_obj_conv.inner = (void*)(this_obj & (~1));
11494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11495         WatchedOutput_free(this_obj_conv);
11496 }
11497
11498 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
11499         LDKWatchedOutput this_ptr_conv;
11500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11501         this_ptr_conv.is_owned = false;
11502         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11503         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
11504         return ret_arr;
11505 }
11506
11507 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
11508         LDKWatchedOutput this_ptr_conv;
11509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11510         this_ptr_conv.is_owned = false;
11511         LDKThirtyTwoBytes val_ref;
11512         CHECK(*((uint32_t*)val) == 32);
11513         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11514         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11515 }
11516
11517 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
11518         LDKWatchedOutput this_ptr_conv;
11519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11520         this_ptr_conv.is_owned = false;
11521         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11524         uint64_t ret_ref = (uint64_t)ret_var.inner;
11525         if (ret_var.is_owned) {
11526                 ret_ref |= 1;
11527         }
11528         return ret_ref;
11529 }
11530
11531 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
11532         LDKWatchedOutput this_ptr_conv;
11533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11534         this_ptr_conv.is_owned = false;
11535         LDKOutPoint val_conv;
11536         val_conv.inner = (void*)(val & (~1));
11537         val_conv.is_owned = (val & 1) || (val == 0);
11538         val_conv = OutPoint_clone(&val_conv);
11539         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11540 }
11541
11542 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
11543         LDKWatchedOutput this_ptr_conv;
11544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11545         this_ptr_conv.is_owned = false;
11546         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
11547         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11548         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11549         return ret_arr;
11550 }
11551
11552 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
11553         LDKWatchedOutput this_ptr_conv;
11554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11555         this_ptr_conv.is_owned = false;
11556         LDKCVec_u8Z val_ref;
11557         val_ref.datalen = *((uint32_t*)val);
11558         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11559         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11560         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11561 }
11562
11563 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
11564         LDKThirtyTwoBytes block_hash_arg_ref;
11565         CHECK(*((uint32_t*)block_hash_arg) == 32);
11566         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
11567         LDKOutPoint outpoint_arg_conv;
11568         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11569         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11570         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11571         LDKCVec_u8Z script_pubkey_arg_ref;
11572         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
11573         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11574         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
11575         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11578         uint64_t ret_ref = (uint64_t)ret_var.inner;
11579         if (ret_var.is_owned) {
11580                 ret_ref |= 1;
11581         }
11582         return ret_ref;
11583 }
11584
11585 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
11586         LDKWatchedOutput orig_conv;
11587         orig_conv.inner = (void*)(orig & (~1));
11588         orig_conv.is_owned = false;
11589         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
11590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11592         uint64_t ret_ref = (uint64_t)ret_var.inner;
11593         if (ret_var.is_owned) {
11594                 ret_ref |= 1;
11595         }
11596         return ret_ref;
11597 }
11598
11599 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
11600         LDKWatchedOutput o_conv;
11601         o_conv.inner = (void*)(o & (~1));
11602         o_conv.is_owned = false;
11603         int64_t ret_val = WatchedOutput_hash(&o_conv);
11604         return ret_val;
11605 }
11606
11607 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
11608         if ((this_ptr & 1) != 0) return;
11609         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11610         FREE((void*)this_ptr);
11611         BroadcasterInterface_free(this_ptr_conv);
11612 }
11613
11614 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
11615         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11616         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
11617         return ret_conv;
11618 }
11619
11620 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
11621         if ((this_ptr & 1) != 0) return;
11622         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11623         FREE((void*)this_ptr);
11624         FeeEstimator_free(this_ptr_conv);
11625 }
11626
11627 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
11628         LDKChainMonitor this_obj_conv;
11629         this_obj_conv.inner = (void*)(this_obj & (~1));
11630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11631         ChainMonitor_free(this_obj_conv);
11632 }
11633
11634 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
11635         LDKFilter *chain_source_conv_ptr = NULL;
11636         if (chain_source != 0) {
11637                 LDKFilter chain_source_conv;
11638                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11639                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11640                 *chain_source_conv_ptr = chain_source_conv;
11641         }
11642         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11643         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11644         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11645         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11646         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11649         uint64_t ret_ref = (uint64_t)ret_var.inner;
11650         if (ret_var.is_owned) {
11651                 ret_ref |= 1;
11652         }
11653         return ret_ref;
11654 }
11655
11656 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
11657         LDKChainMonitor this_arg_conv;
11658         this_arg_conv.inner = (void*)(this_arg & (~1));
11659         this_arg_conv.is_owned = false;
11660         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11661         *ret = ChainMonitor_as_Listen(&this_arg_conv);
11662         return (uint64_t)ret;
11663 }
11664
11665 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
11666         LDKChainMonitor this_arg_conv;
11667         this_arg_conv.inner = (void*)(this_arg & (~1));
11668         this_arg_conv.is_owned = false;
11669         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11670         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
11671         return (uint64_t)ret;
11672 }
11673
11674 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
11675         LDKChainMonitor this_arg_conv;
11676         this_arg_conv.inner = (void*)(this_arg & (~1));
11677         this_arg_conv.is_owned = false;
11678         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11679         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11680         return (uint64_t)ret;
11681 }
11682
11683 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
11684         LDKChainMonitor this_arg_conv;
11685         this_arg_conv.inner = (void*)(this_arg & (~1));
11686         this_arg_conv.is_owned = false;
11687         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11688         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11689         return (uint64_t)ret;
11690 }
11691
11692 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
11693         LDKChannelMonitorUpdate this_obj_conv;
11694         this_obj_conv.inner = (void*)(this_obj & (~1));
11695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11696         ChannelMonitorUpdate_free(this_obj_conv);
11697 }
11698
11699 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
11700         LDKChannelMonitorUpdate this_ptr_conv;
11701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11702         this_ptr_conv.is_owned = false;
11703         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11704         return ret_val;
11705 }
11706
11707 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
11708         LDKChannelMonitorUpdate this_ptr_conv;
11709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11710         this_ptr_conv.is_owned = false;
11711         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11712 }
11713
11714 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
11715         LDKChannelMonitorUpdate orig_conv;
11716         orig_conv.inner = (void*)(orig & (~1));
11717         orig_conv.is_owned = false;
11718         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11721         uint64_t ret_ref = (uint64_t)ret_var.inner;
11722         if (ret_var.is_owned) {
11723                 ret_ref |= 1;
11724         }
11725         return ret_ref;
11726 }
11727
11728 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
11729         LDKChannelMonitorUpdate obj_conv;
11730         obj_conv.inner = (void*)(obj & (~1));
11731         obj_conv.is_owned = false;
11732         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11733         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11734         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11735         CVec_u8Z_free(ret_var);
11736         return ret_arr;
11737 }
11738
11739 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
11740         LDKu8slice ser_ref;
11741         ser_ref.datalen = *((uint32_t*)ser);
11742         ser_ref.data = (int8_t*)(ser + 4);
11743         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11744         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11745         return (uint64_t)ret_conv;
11746 }
11747
11748 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
11749         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11750         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
11751         return ret_conv;
11752 }
11753
11754 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
11755         LDKMonitorUpdateError this_obj_conv;
11756         this_obj_conv.inner = (void*)(this_obj & (~1));
11757         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11758         MonitorUpdateError_free(this_obj_conv);
11759 }
11760
11761 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
11762         LDKMonitorUpdateError orig_conv;
11763         orig_conv.inner = (void*)(orig & (~1));
11764         orig_conv.is_owned = false;
11765         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11768         uint64_t ret_ref = (uint64_t)ret_var.inner;
11769         if (ret_var.is_owned) {
11770                 ret_ref |= 1;
11771         }
11772         return ret_ref;
11773 }
11774
11775 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
11776         if ((this_ptr & 1) != 0) return;
11777         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11778         FREE((void*)this_ptr);
11779         MonitorEvent_free(this_ptr_conv);
11780 }
11781
11782 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
11783         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11784         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11785         *ret_copy = MonitorEvent_clone(orig_conv);
11786         uint64_t ret_ref = (uint64_t)ret_copy;
11787         return ret_ref;
11788 }
11789
11790 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
11791         LDKHTLCUpdate this_obj_conv;
11792         this_obj_conv.inner = (void*)(this_obj & (~1));
11793         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11794         HTLCUpdate_free(this_obj_conv);
11795 }
11796
11797 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
11798         LDKHTLCUpdate orig_conv;
11799         orig_conv.inner = (void*)(orig & (~1));
11800         orig_conv.is_owned = false;
11801         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11804         uint64_t ret_ref = (uint64_t)ret_var.inner;
11805         if (ret_var.is_owned) {
11806                 ret_ref |= 1;
11807         }
11808         return ret_ref;
11809 }
11810
11811 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
11812         LDKHTLCUpdate obj_conv;
11813         obj_conv.inner = (void*)(obj & (~1));
11814         obj_conv.is_owned = false;
11815         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11816         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11817         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11818         CVec_u8Z_free(ret_var);
11819         return ret_arr;
11820 }
11821
11822 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
11823         LDKu8slice ser_ref;
11824         ser_ref.datalen = *((uint32_t*)ser);
11825         ser_ref.data = (int8_t*)(ser + 4);
11826         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11827         *ret_conv = HTLCUpdate_read(ser_ref);
11828         return (uint64_t)ret_conv;
11829 }
11830
11831 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
11832         LDKChannelMonitor this_obj_conv;
11833         this_obj_conv.inner = (void*)(this_obj & (~1));
11834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11835         ChannelMonitor_free(this_obj_conv);
11836 }
11837
11838 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
11839         LDKChannelMonitor orig_conv;
11840         orig_conv.inner = (void*)(orig & (~1));
11841         orig_conv.is_owned = false;
11842         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11845         uint64_t ret_ref = (uint64_t)ret_var.inner;
11846         if (ret_var.is_owned) {
11847                 ret_ref |= 1;
11848         }
11849         return ret_ref;
11850 }
11851
11852 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
11853         LDKChannelMonitor obj_conv;
11854         obj_conv.inner = (void*)(obj & (~1));
11855         obj_conv.is_owned = false;
11856         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11857         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11858         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11859         CVec_u8Z_free(ret_var);
11860         return ret_arr;
11861 }
11862
11863 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) {
11864         LDKChannelMonitor this_arg_conv;
11865         this_arg_conv.inner = (void*)(this_arg & (~1));
11866         this_arg_conv.is_owned = false;
11867         LDKChannelMonitorUpdate updates_conv;
11868         updates_conv.inner = (void*)(updates & (~1));
11869         updates_conv.is_owned = false;
11870         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11871         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11872         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11873         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11874         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11875         return (uint64_t)ret_conv;
11876 }
11877
11878 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
11879         LDKChannelMonitor this_arg_conv;
11880         this_arg_conv.inner = (void*)(this_arg & (~1));
11881         this_arg_conv.is_owned = false;
11882         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11883         return ret_val;
11884 }
11885
11886 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
11887         LDKChannelMonitor this_arg_conv;
11888         this_arg_conv.inner = (void*)(this_arg & (~1));
11889         this_arg_conv.is_owned = false;
11890         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11891         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11892         return (uint64_t)ret_ref;
11893 }
11894
11895 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
11896         LDKChannelMonitor this_arg_conv;
11897         this_arg_conv.inner = (void*)(this_arg & (~1));
11898         this_arg_conv.is_owned = false;
11899         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11900         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11901         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11902         for (size_t c = 0; c < ret_var.datalen; c++) {
11903                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11904                 *ret_conv_54_ref = ret_var.data[c];
11905                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
11906         }
11907         FREE(ret_var.data);
11908         return ret_arr;
11909 }
11910
11911 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
11912         LDKChannelMonitor this_arg_conv;
11913         this_arg_conv.inner = (void*)(this_arg & (~1));
11914         this_arg_conv.is_owned = false;
11915         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11916         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11917 }
11918
11919 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
11920         LDKChannelMonitor this_arg_conv;
11921         this_arg_conv.inner = (void*)(this_arg & (~1));
11922         this_arg_conv.is_owned = false;
11923         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11924         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11925         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11926         for (size_t o = 0; o < ret_var.datalen; o++) {
11927                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11928                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11929                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
11930                 ret_arr_ptr[o] = ret_conv_14_ref;
11931         }
11932         FREE(ret_var.data);
11933         return ret_arr;
11934 }
11935
11936 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
11937         LDKChannelMonitor this_arg_conv;
11938         this_arg_conv.inner = (void*)(this_arg & (~1));
11939         this_arg_conv.is_owned = false;
11940         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11941         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11942         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11943         for (size_t h = 0; h < ret_var.datalen; h++) {
11944                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11945                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11946                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
11947                 ret_arr_ptr[h] = ret_conv_7_ref;
11948         }
11949         FREE(ret_var.data);
11950         return ret_arr;
11951 }
11952
11953 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
11954         LDKChannelMonitor this_arg_conv;
11955         this_arg_conv.inner = (void*)(this_arg & (~1));
11956         this_arg_conv.is_owned = false;
11957         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11958         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11959         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11960         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11961         for (size_t m = 0; m < ret_var.datalen; m++) {
11962                 LDKTransaction ret_conv_12_var = ret_var.data[m];
11963                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11964                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
11965                 Transaction_free(ret_conv_12_var);
11966                 ret_arr_ptr[m] = ret_conv_12_arr;
11967         }
11968         FREE(ret_var.data);
11969         return ret_arr;
11970 }
11971
11972 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) {
11973         LDKChannelMonitor this_arg_conv;
11974         this_arg_conv.inner = (void*)(this_arg & (~1));
11975         this_arg_conv.is_owned = false;
11976         unsigned char header_arr[80];
11977         CHECK(*((uint32_t*)header) == 80);
11978         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11979         unsigned char (*header_ref)[80] = &header_arr;
11980         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11981         txdata_constr.datalen = *((uint32_t*)txdata);
11982         if (txdata_constr.datalen > 0)
11983                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11984         else
11985                 txdata_constr.data = NULL;
11986         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11987         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11988                 uint32_t txdata_conv_30 = txdata_vals[e];
11989                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11990                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11991                 txdata_constr.data[e] = txdata_conv_30_conv;
11992         }
11993         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11994         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11995         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11996         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);
11997         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11998         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11999         for (size_t x = 0; x < ret_var.datalen; x++) {
12000                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12001                 *ret_conv_49_ref = ret_var.data[x];
12002                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12003         }
12004         FREE(ret_var.data);
12005         return ret_arr;
12006 }
12007
12008 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) {
12009         LDKChannelMonitor this_arg_conv;
12010         this_arg_conv.inner = (void*)(this_arg & (~1));
12011         this_arg_conv.is_owned = false;
12012         unsigned char header_arr[80];
12013         CHECK(*((uint32_t*)header) == 80);
12014         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12015         unsigned char (*header_ref)[80] = &header_arr;
12016         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12017         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12018         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12019         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12020 }
12021
12022 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) {
12023         LDKChannelMonitor this_arg_conv;
12024         this_arg_conv.inner = (void*)(this_arg & (~1));
12025         this_arg_conv.is_owned = false;
12026         unsigned char header_arr[80];
12027         CHECK(*((uint32_t*)header) == 80);
12028         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12029         unsigned char (*header_ref)[80] = &header_arr;
12030         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12031         txdata_constr.datalen = *((uint32_t*)txdata);
12032         if (txdata_constr.datalen > 0)
12033                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12034         else
12035                 txdata_constr.data = NULL;
12036         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
12037         for (size_t e = 0; e < txdata_constr.datalen; e++) {
12038                 uint32_t txdata_conv_30 = txdata_vals[e];
12039                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
12040                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
12041                 txdata_constr.data[e] = txdata_conv_30_conv;
12042         }
12043         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12044         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12045         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12046         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);
12047         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12048         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12049         for (size_t x = 0; x < ret_var.datalen; x++) {
12050                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12051                 *ret_conv_49_ref = ret_var.data[x];
12052                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12053         }
12054         FREE(ret_var.data);
12055         return ret_arr;
12056 }
12057
12058 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) {
12059         LDKChannelMonitor this_arg_conv;
12060         this_arg_conv.inner = (void*)(this_arg & (~1));
12061         this_arg_conv.is_owned = false;
12062         unsigned char txid_arr[32];
12063         CHECK(*((uint32_t*)txid) == 32);
12064         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
12065         unsigned char (*txid_ref)[32] = &txid_arr;
12066         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12067         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12068         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12069         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
12070 }
12071
12072 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
12073         LDKChannelMonitor this_arg_conv;
12074         this_arg_conv.inner = (void*)(this_arg & (~1));
12075         this_arg_conv.is_owned = false;
12076         unsigned char header_arr[80];
12077         CHECK(*((uint32_t*)header) == 80);
12078         memcpy(header_arr, (uint8_t*)(header + 4), 80);
12079         unsigned char (*header_ref)[80] = &header_arr;
12080         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
12081         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
12082         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12083         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
12084         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
12085         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
12086         for (size_t x = 0; x < ret_var.datalen; x++) {
12087                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12088                 *ret_conv_49_ref = ret_var.data[x];
12089                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
12090         }
12091         FREE(ret_var.data);
12092         return ret_arr;
12093 }
12094
12095 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
12096         LDKChannelMonitor this_arg_conv;
12097         this_arg_conv.inner = (void*)(this_arg & (~1));
12098         this_arg_conv.is_owned = false;
12099         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
12100         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12101         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12102         for (size_t m = 0; m < ret_var.datalen; m++) {
12103                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12104                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
12105                 ret_arr_ptr[m] = ret_conv_12_arr;
12106         }
12107         FREE(ret_var.data);
12108         return ret_arr;
12109 }
12110
12111 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
12112         LDKChannelMonitor this_arg_conv;
12113         this_arg_conv.inner = (void*)(this_arg & (~1));
12114         this_arg_conv.is_owned = false;
12115         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
12116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12118         uint64_t ret_ref = (uint64_t)ret_var.inner;
12119         if (ret_var.is_owned) {
12120                 ret_ref |= 1;
12121         }
12122         return ret_ref;
12123 }
12124
12125 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
12126         if ((this_ptr & 1) != 0) return;
12127         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
12128         FREE((void*)this_ptr);
12129         Persist_free(this_ptr_conv);
12130 }
12131
12132 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
12133         LDKu8slice ser_ref;
12134         ser_ref.datalen = *((uint32_t*)ser);
12135         ser_ref.data = (int8_t*)(ser + 4);
12136         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
12137         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12138         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
12139         return (uint64_t)ret_conv;
12140 }
12141
12142 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
12143         LDKOutPoint this_obj_conv;
12144         this_obj_conv.inner = (void*)(this_obj & (~1));
12145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12146         OutPoint_free(this_obj_conv);
12147 }
12148
12149 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
12150         LDKOutPoint this_ptr_conv;
12151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12152         this_ptr_conv.is_owned = false;
12153         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12154         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
12155         return ret_arr;
12156 }
12157
12158 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
12159         LDKOutPoint this_ptr_conv;
12160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12161         this_ptr_conv.is_owned = false;
12162         LDKThirtyTwoBytes val_ref;
12163         CHECK(*((uint32_t*)val) == 32);
12164         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12165         OutPoint_set_txid(&this_ptr_conv, val_ref);
12166 }
12167
12168 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
12169         LDKOutPoint this_ptr_conv;
12170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12171         this_ptr_conv.is_owned = false;
12172         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
12173         return ret_val;
12174 }
12175
12176 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
12177         LDKOutPoint this_ptr_conv;
12178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12179         this_ptr_conv.is_owned = false;
12180         OutPoint_set_index(&this_ptr_conv, val);
12181 }
12182
12183 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
12184         LDKThirtyTwoBytes txid_arg_ref;
12185         CHECK(*((uint32_t*)txid_arg) == 32);
12186         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
12187         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
12188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12190         uint64_t ret_ref = (uint64_t)ret_var.inner;
12191         if (ret_var.is_owned) {
12192                 ret_ref |= 1;
12193         }
12194         return ret_ref;
12195 }
12196
12197 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
12198         LDKOutPoint orig_conv;
12199         orig_conv.inner = (void*)(orig & (~1));
12200         orig_conv.is_owned = false;
12201         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
12202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12204         uint64_t ret_ref = (uint64_t)ret_var.inner;
12205         if (ret_var.is_owned) {
12206                 ret_ref |= 1;
12207         }
12208         return ret_ref;
12209 }
12210
12211 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
12212         LDKOutPoint a_conv;
12213         a_conv.inner = (void*)(a & (~1));
12214         a_conv.is_owned = false;
12215         LDKOutPoint b_conv;
12216         b_conv.inner = (void*)(b & (~1));
12217         b_conv.is_owned = false;
12218         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
12219         return ret_val;
12220 }
12221
12222 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
12223         LDKOutPoint o_conv;
12224         o_conv.inner = (void*)(o & (~1));
12225         o_conv.is_owned = false;
12226         int64_t ret_val = OutPoint_hash(&o_conv);
12227         return ret_val;
12228 }
12229
12230 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
12231         LDKOutPoint this_arg_conv;
12232         this_arg_conv.inner = (void*)(this_arg & (~1));
12233         this_arg_conv.is_owned = false;
12234         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12235         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
12236         return ret_arr;
12237 }
12238
12239 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
12240         LDKOutPoint obj_conv;
12241         obj_conv.inner = (void*)(obj & (~1));
12242         obj_conv.is_owned = false;
12243         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
12244         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12245         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12246         CVec_u8Z_free(ret_var);
12247         return ret_arr;
12248 }
12249
12250 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
12251         LDKu8slice ser_ref;
12252         ser_ref.datalen = *((uint32_t*)ser);
12253         ser_ref.data = (int8_t*)(ser + 4);
12254         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12255         *ret_conv = OutPoint_read(ser_ref);
12256         return (uint64_t)ret_conv;
12257 }
12258
12259 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
12260         LDKDelayedPaymentOutputDescriptor this_obj_conv;
12261         this_obj_conv.inner = (void*)(this_obj & (~1));
12262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12263         DelayedPaymentOutputDescriptor_free(this_obj_conv);
12264 }
12265
12266 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12267         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12269         this_ptr_conv.is_owned = false;
12270         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12271         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12272         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12273         uint64_t ret_ref = (uint64_t)ret_var.inner;
12274         if (ret_var.is_owned) {
12275                 ret_ref |= 1;
12276         }
12277         return ret_ref;
12278 }
12279
12280 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12281         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12283         this_ptr_conv.is_owned = false;
12284         LDKOutPoint val_conv;
12285         val_conv.inner = (void*)(val & (~1));
12286         val_conv.is_owned = (val & 1) || (val == 0);
12287         val_conv = OutPoint_clone(&val_conv);
12288         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12289 }
12290
12291 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
12292         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12294         this_ptr_conv.is_owned = false;
12295         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12296         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12297         return ret_arr;
12298 }
12299
12300 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12301         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12303         this_ptr_conv.is_owned = false;
12304         LDKPublicKey val_ref;
12305         CHECK(*((uint32_t*)val) == 33);
12306         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12307         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
12308 }
12309
12310 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
12311         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12313         this_ptr_conv.is_owned = false;
12314         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
12315         return ret_val;
12316 }
12317
12318 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12319         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12321         this_ptr_conv.is_owned = false;
12322         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
12323 }
12324
12325 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12326         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12328         this_ptr_conv.is_owned = false;
12329         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12330         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12331 }
12332
12333 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
12334         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12336         this_ptr_conv.is_owned = false;
12337         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12338         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
12339         return ret_arr;
12340 }
12341
12342 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
12343         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12345         this_ptr_conv.is_owned = false;
12346         LDKPublicKey val_ref;
12347         CHECK(*((uint32_t*)val) == 33);
12348         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12349         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
12350 }
12351
12352 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12353         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12355         this_ptr_conv.is_owned = false;
12356         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12357         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12358         return ret_arr;
12359 }
12360
12361 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12362         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12364         this_ptr_conv.is_owned = false;
12365         LDKThirtyTwoBytes val_ref;
12366         CHECK(*((uint32_t*)val) == 32);
12367         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12368         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12369 }
12370
12371 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12372         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12374         this_ptr_conv.is_owned = false;
12375         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12376         return ret_val;
12377 }
12378
12379 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12380         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12382         this_ptr_conv.is_owned = false;
12383         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12384 }
12385
12386 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) {
12387         LDKOutPoint outpoint_arg_conv;
12388         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12389         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12390         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12391         LDKPublicKey per_commitment_point_arg_ref;
12392         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
12393         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
12394         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12395         LDKPublicKey revocation_pubkey_arg_ref;
12396         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
12397         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
12398         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12399         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12400         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12401         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);
12402         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12403         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12404         uint64_t ret_ref = (uint64_t)ret_var.inner;
12405         if (ret_var.is_owned) {
12406                 ret_ref |= 1;
12407         }
12408         return ret_ref;
12409 }
12410
12411 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
12412         LDKDelayedPaymentOutputDescriptor orig_conv;
12413         orig_conv.inner = (void*)(orig & (~1));
12414         orig_conv.is_owned = false;
12415         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12416         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12417         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12418         uint64_t ret_ref = (uint64_t)ret_var.inner;
12419         if (ret_var.is_owned) {
12420                 ret_ref |= 1;
12421         }
12422         return ret_ref;
12423 }
12424
12425 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
12426         LDKDelayedPaymentOutputDescriptor obj_conv;
12427         obj_conv.inner = (void*)(obj & (~1));
12428         obj_conv.is_owned = false;
12429         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
12430         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12431         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12432         CVec_u8Z_free(ret_var);
12433         return ret_arr;
12434 }
12435
12436 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
12437         LDKu8slice ser_ref;
12438         ser_ref.datalen = *((uint32_t*)ser);
12439         ser_ref.data = (int8_t*)(ser + 4);
12440         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12441         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
12442         return (uint64_t)ret_conv;
12443 }
12444
12445 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
12446         LDKStaticPaymentOutputDescriptor this_obj_conv;
12447         this_obj_conv.inner = (void*)(this_obj & (~1));
12448         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12449         StaticPaymentOutputDescriptor_free(this_obj_conv);
12450 }
12451
12452 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12453         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12455         this_ptr_conv.is_owned = false;
12456         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12459         uint64_t ret_ref = (uint64_t)ret_var.inner;
12460         if (ret_var.is_owned) {
12461                 ret_ref |= 1;
12462         }
12463         return ret_ref;
12464 }
12465
12466 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12467         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12469         this_ptr_conv.is_owned = false;
12470         LDKOutPoint val_conv;
12471         val_conv.inner = (void*)(val & (~1));
12472         val_conv.is_owned = (val & 1) || (val == 0);
12473         val_conv = OutPoint_clone(&val_conv);
12474         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12475 }
12476
12477 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12478         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12480         this_ptr_conv.is_owned = false;
12481         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12482         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12483 }
12484
12485 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12486         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12488         this_ptr_conv.is_owned = false;
12489         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12490         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12491         return ret_arr;
12492 }
12493
12494 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12495         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12497         this_ptr_conv.is_owned = false;
12498         LDKThirtyTwoBytes val_ref;
12499         CHECK(*((uint32_t*)val) == 32);
12500         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12501         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12502 }
12503
12504 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12505         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12507         this_ptr_conv.is_owned = false;
12508         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12509         return ret_val;
12510 }
12511
12512 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12513         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12515         this_ptr_conv.is_owned = false;
12516         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12517 }
12518
12519 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) {
12520         LDKOutPoint outpoint_arg_conv;
12521         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12522         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12523         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12524         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12525         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12526         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12527         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12528         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12531         uint64_t ret_ref = (uint64_t)ret_var.inner;
12532         if (ret_var.is_owned) {
12533                 ret_ref |= 1;
12534         }
12535         return ret_ref;
12536 }
12537
12538 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
12539         LDKStaticPaymentOutputDescriptor orig_conv;
12540         orig_conv.inner = (void*)(orig & (~1));
12541         orig_conv.is_owned = false;
12542         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12545         uint64_t ret_ref = (uint64_t)ret_var.inner;
12546         if (ret_var.is_owned) {
12547                 ret_ref |= 1;
12548         }
12549         return ret_ref;
12550 }
12551
12552 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
12553         LDKStaticPaymentOutputDescriptor obj_conv;
12554         obj_conv.inner = (void*)(obj & (~1));
12555         obj_conv.is_owned = false;
12556         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
12557         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12558         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12559         CVec_u8Z_free(ret_var);
12560         return ret_arr;
12561 }
12562
12563 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
12564         LDKu8slice ser_ref;
12565         ser_ref.datalen = *((uint32_t*)ser);
12566         ser_ref.data = (int8_t*)(ser + 4);
12567         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12568         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
12569         return (uint64_t)ret_conv;
12570 }
12571
12572 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
12573         if ((this_ptr & 1) != 0) return;
12574         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12575         FREE((void*)this_ptr);
12576         SpendableOutputDescriptor_free(this_ptr_conv);
12577 }
12578
12579 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
12580         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12581         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12582         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12583         uint64_t ret_ref = (uint64_t)ret_copy;
12584         return ret_ref;
12585 }
12586
12587 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
12588         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12589         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12590         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12591         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12592         CVec_u8Z_free(ret_var);
12593         return ret_arr;
12594 }
12595
12596 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
12597         LDKu8slice ser_ref;
12598         ser_ref.datalen = *((uint32_t*)ser);
12599         ser_ref.data = (int8_t*)(ser + 4);
12600         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12601         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12602         return (uint64_t)ret_conv;
12603 }
12604
12605 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
12606         if ((this_ptr & 1) != 0) return;
12607         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12608         FREE((void*)this_ptr);
12609         BaseSign_free(this_ptr_conv);
12610 }
12611
12612 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
12613         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12614         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12615         *ret = Sign_clone(orig_conv);
12616         return (uint64_t)ret;
12617 }
12618
12619 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
12620         if ((this_ptr & 1) != 0) return;
12621         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12622         FREE((void*)this_ptr);
12623         Sign_free(this_ptr_conv);
12624 }
12625
12626 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
12627         if ((this_ptr & 1) != 0) return;
12628         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12629         FREE((void*)this_ptr);
12630         KeysInterface_free(this_ptr_conv);
12631 }
12632
12633 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
12634         LDKInMemorySigner this_obj_conv;
12635         this_obj_conv.inner = (void*)(this_obj & (~1));
12636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12637         InMemorySigner_free(this_obj_conv);
12638 }
12639
12640 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
12641         LDKInMemorySigner this_ptr_conv;
12642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12643         this_ptr_conv.is_owned = false;
12644         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12645         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
12646         return ret_arr;
12647 }
12648
12649 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
12650         LDKInMemorySigner this_ptr_conv;
12651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12652         this_ptr_conv.is_owned = false;
12653         LDKSecretKey val_ref;
12654         CHECK(*((uint32_t*)val) == 32);
12655         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12656         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12657 }
12658
12659 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
12660         LDKInMemorySigner this_ptr_conv;
12661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12662         this_ptr_conv.is_owned = false;
12663         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12664         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
12665         return ret_arr;
12666 }
12667
12668 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
12669         LDKInMemorySigner this_ptr_conv;
12670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12671         this_ptr_conv.is_owned = false;
12672         LDKSecretKey val_ref;
12673         CHECK(*((uint32_t*)val) == 32);
12674         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12675         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12676 }
12677
12678 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
12679         LDKInMemorySigner this_ptr_conv;
12680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12681         this_ptr_conv.is_owned = false;
12682         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12683         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
12684         return ret_arr;
12685 }
12686
12687 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
12688         LDKInMemorySigner this_ptr_conv;
12689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12690         this_ptr_conv.is_owned = false;
12691         LDKSecretKey val_ref;
12692         CHECK(*((uint32_t*)val) == 32);
12693         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12694         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12695 }
12696
12697 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
12698         LDKInMemorySigner this_ptr_conv;
12699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12700         this_ptr_conv.is_owned = false;
12701         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12702         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
12703         return ret_arr;
12704 }
12705
12706 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
12707         LDKInMemorySigner this_ptr_conv;
12708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12709         this_ptr_conv.is_owned = false;
12710         LDKSecretKey val_ref;
12711         CHECK(*((uint32_t*)val) == 32);
12712         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12713         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12714 }
12715
12716 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
12717         LDKInMemorySigner this_ptr_conv;
12718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12719         this_ptr_conv.is_owned = false;
12720         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12721         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
12722         return ret_arr;
12723 }
12724
12725 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
12726         LDKInMemorySigner this_ptr_conv;
12727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12728         this_ptr_conv.is_owned = false;
12729         LDKSecretKey val_ref;
12730         CHECK(*((uint32_t*)val) == 32);
12731         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12732         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12733 }
12734
12735 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
12736         LDKInMemorySigner this_ptr_conv;
12737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12738         this_ptr_conv.is_owned = false;
12739         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12740         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
12741         return ret_arr;
12742 }
12743
12744 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
12745         LDKInMemorySigner this_ptr_conv;
12746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12747         this_ptr_conv.is_owned = false;
12748         LDKThirtyTwoBytes val_ref;
12749         CHECK(*((uint32_t*)val) == 32);
12750         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12751         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12752 }
12753
12754 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
12755         LDKInMemorySigner orig_conv;
12756         orig_conv.inner = (void*)(orig & (~1));
12757         orig_conv.is_owned = false;
12758         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12761         uint64_t ret_ref = (uint64_t)ret_var.inner;
12762         if (ret_var.is_owned) {
12763                 ret_ref |= 1;
12764         }
12765         return ret_ref;
12766 }
12767
12768 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) {
12769         LDKSecretKey funding_key_ref;
12770         CHECK(*((uint32_t*)funding_key) == 32);
12771         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
12772         LDKSecretKey revocation_base_key_ref;
12773         CHECK(*((uint32_t*)revocation_base_key) == 32);
12774         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
12775         LDKSecretKey payment_key_ref;
12776         CHECK(*((uint32_t*)payment_key) == 32);
12777         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
12778         LDKSecretKey delayed_payment_base_key_ref;
12779         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
12780         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
12781         LDKSecretKey htlc_base_key_ref;
12782         CHECK(*((uint32_t*)htlc_base_key) == 32);
12783         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
12784         LDKThirtyTwoBytes commitment_seed_ref;
12785         CHECK(*((uint32_t*)commitment_seed) == 32);
12786         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
12787         LDKThirtyTwoBytes channel_keys_id_ref;
12788         CHECK(*((uint32_t*)channel_keys_id) == 32);
12789         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
12790         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);
12791         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12792         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12793         uint64_t ret_ref = (uint64_t)ret_var.inner;
12794         if (ret_var.is_owned) {
12795                 ret_ref |= 1;
12796         }
12797         return ret_ref;
12798 }
12799
12800 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
12801         LDKInMemorySigner this_arg_conv;
12802         this_arg_conv.inner = (void*)(this_arg & (~1));
12803         this_arg_conv.is_owned = false;
12804         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12807         uint64_t ret_ref = (uint64_t)ret_var.inner;
12808         if (ret_var.is_owned) {
12809                 ret_ref |= 1;
12810         }
12811         return ret_ref;
12812 }
12813
12814 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
12815         LDKInMemorySigner this_arg_conv;
12816         this_arg_conv.inner = (void*)(this_arg & (~1));
12817         this_arg_conv.is_owned = false;
12818         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12819         return ret_val;
12820 }
12821
12822 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
12823         LDKInMemorySigner this_arg_conv;
12824         this_arg_conv.inner = (void*)(this_arg & (~1));
12825         this_arg_conv.is_owned = false;
12826         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12827         return ret_val;
12828 }
12829
12830 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
12831         LDKInMemorySigner this_arg_conv;
12832         this_arg_conv.inner = (void*)(this_arg & (~1));
12833         this_arg_conv.is_owned = false;
12834         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12835         return ret_val;
12836 }
12837
12838 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
12839         LDKInMemorySigner this_arg_conv;
12840         this_arg_conv.inner = (void*)(this_arg & (~1));
12841         this_arg_conv.is_owned = false;
12842         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
12843         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12844         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12845         uint64_t ret_ref = (uint64_t)ret_var.inner;
12846         if (ret_var.is_owned) {
12847                 ret_ref |= 1;
12848         }
12849         return ret_ref;
12850 }
12851
12852 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
12853         LDKInMemorySigner this_arg_conv;
12854         this_arg_conv.inner = (void*)(this_arg & (~1));
12855         this_arg_conv.is_owned = false;
12856         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12859         uint64_t ret_ref = (uint64_t)ret_var.inner;
12860         if (ret_var.is_owned) {
12861                 ret_ref |= 1;
12862         }
12863         return ret_ref;
12864 }
12865
12866 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) {
12867         LDKInMemorySigner this_arg_conv;
12868         this_arg_conv.inner = (void*)(this_arg & (~1));
12869         this_arg_conv.is_owned = false;
12870         LDKTransaction spend_tx_ref;
12871         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12872         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12873         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12874         spend_tx_ref.data_is_owned = true;
12875         LDKStaticPaymentOutputDescriptor descriptor_conv;
12876         descriptor_conv.inner = (void*)(descriptor & (~1));
12877         descriptor_conv.is_owned = false;
12878         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12879         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12880         return (uint64_t)ret_conv;
12881 }
12882
12883 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) {
12884         LDKInMemorySigner this_arg_conv;
12885         this_arg_conv.inner = (void*)(this_arg & (~1));
12886         this_arg_conv.is_owned = false;
12887         LDKTransaction spend_tx_ref;
12888         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12889         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12890         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12891         spend_tx_ref.data_is_owned = true;
12892         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12893         descriptor_conv.inner = (void*)(descriptor & (~1));
12894         descriptor_conv.is_owned = false;
12895         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12896         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12897         return (uint64_t)ret_conv;
12898 }
12899
12900 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
12901         LDKInMemorySigner this_arg_conv;
12902         this_arg_conv.inner = (void*)(this_arg & (~1));
12903         this_arg_conv.is_owned = false;
12904         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12905         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12906         return (uint64_t)ret;
12907 }
12908
12909 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
12910         LDKInMemorySigner this_arg_conv;
12911         this_arg_conv.inner = (void*)(this_arg & (~1));
12912         this_arg_conv.is_owned = false;
12913         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12914         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12915         return (uint64_t)ret;
12916 }
12917
12918 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
12919         LDKInMemorySigner obj_conv;
12920         obj_conv.inner = (void*)(obj & (~1));
12921         obj_conv.is_owned = false;
12922         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12923         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12924         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12925         CVec_u8Z_free(ret_var);
12926         return ret_arr;
12927 }
12928
12929 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
12930         LDKu8slice ser_ref;
12931         ser_ref.datalen = *((uint32_t*)ser);
12932         ser_ref.data = (int8_t*)(ser + 4);
12933         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12934         *ret_conv = InMemorySigner_read(ser_ref);
12935         return (uint64_t)ret_conv;
12936 }
12937
12938 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
12939         LDKKeysManager this_obj_conv;
12940         this_obj_conv.inner = (void*)(this_obj & (~1));
12941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12942         KeysManager_free(this_obj_conv);
12943 }
12944
12945 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
12946         unsigned char seed_arr[32];
12947         CHECK(*((uint32_t*)seed) == 32);
12948         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
12949         unsigned char (*seed_ref)[32] = &seed_arr;
12950         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12953         uint64_t ret_ref = (uint64_t)ret_var.inner;
12954         if (ret_var.is_owned) {
12955                 ret_ref |= 1;
12956         }
12957         return ret_ref;
12958 }
12959
12960 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
12961         LDKKeysManager this_arg_conv;
12962         this_arg_conv.inner = (void*)(this_arg & (~1));
12963         this_arg_conv.is_owned = false;
12964         unsigned char params_arr[32];
12965         CHECK(*((uint32_t*)params) == 32);
12966         memcpy(params_arr, (uint8_t*)(params + 4), 32);
12967         unsigned char (*params_ref)[32] = &params_arr;
12968         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12971         uint64_t ret_ref = (uint64_t)ret_var.inner;
12972         if (ret_var.is_owned) {
12973                 ret_ref |= 1;
12974         }
12975         return ret_ref;
12976 }
12977
12978 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) {
12979         LDKKeysManager this_arg_conv;
12980         this_arg_conv.inner = (void*)(this_arg & (~1));
12981         this_arg_conv.is_owned = false;
12982         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12983         descriptors_constr.datalen = *((uint32_t*)descriptors);
12984         if (descriptors_constr.datalen > 0)
12985                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12986         else
12987                 descriptors_constr.data = NULL;
12988         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
12989         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12990                 uint32_t descriptors_conv_27 = descriptors_vals[b];
12991                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12992                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12993                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12994         }
12995         LDKCVec_TxOutZ outputs_constr;
12996         outputs_constr.datalen = *((uint32_t*)outputs);
12997         if (outputs_constr.datalen > 0)
12998                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12999         else
13000                 outputs_constr.data = NULL;
13001         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
13002         for (size_t h = 0; h < outputs_constr.datalen; h++) {
13003                 uint32_t outputs_conv_7 = outputs_vals[h];
13004                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
13005                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
13006                 outputs_constr.data[h] = outputs_conv_7_conv;
13007         }
13008         LDKCVec_u8Z change_destination_script_ref;
13009         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
13010         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
13011         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
13012         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13013         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
13014         return (uint64_t)ret_conv;
13015 }
13016
13017 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
13018         LDKKeysManager this_arg_conv;
13019         this_arg_conv.inner = (void*)(this_arg & (~1));
13020         this_arg_conv.is_owned = false;
13021         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
13022         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
13023         return (uint64_t)ret;
13024 }
13025
13026 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
13027         LDKChannelManager this_obj_conv;
13028         this_obj_conv.inner = (void*)(this_obj & (~1));
13029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13030         ChannelManager_free(this_obj_conv);
13031 }
13032
13033 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
13034         LDKChainParameters this_obj_conv;
13035         this_obj_conv.inner = (void*)(this_obj & (~1));
13036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13037         ChainParameters_free(this_obj_conv);
13038 }
13039
13040 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
13041         LDKChainParameters this_ptr_conv;
13042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13043         this_ptr_conv.is_owned = false;
13044         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
13045         return ret_conv;
13046 }
13047
13048 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
13049         LDKChainParameters this_ptr_conv;
13050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13051         this_ptr_conv.is_owned = false;
13052         LDKNetwork val_conv = LDKNetwork_from_js(val);
13053         ChainParameters_set_network(&this_ptr_conv, val_conv);
13054 }
13055
13056 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
13057         LDKChainParameters this_ptr_conv;
13058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13059         this_ptr_conv.is_owned = false;
13060         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
13061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13063         uint64_t ret_ref = (uint64_t)ret_var.inner;
13064         if (ret_var.is_owned) {
13065                 ret_ref |= 1;
13066         }
13067         return ret_ref;
13068 }
13069
13070 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
13071         LDKChainParameters this_ptr_conv;
13072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13073         this_ptr_conv.is_owned = false;
13074         LDKBestBlock val_conv;
13075         val_conv.inner = (void*)(val & (~1));
13076         val_conv.is_owned = (val & 1) || (val == 0);
13077         val_conv = BestBlock_clone(&val_conv);
13078         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
13079 }
13080
13081 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
13082         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
13083         LDKBestBlock best_block_arg_conv;
13084         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
13085         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
13086         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
13087         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
13088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13090         uint64_t ret_ref = (uint64_t)ret_var.inner;
13091         if (ret_var.is_owned) {
13092                 ret_ref |= 1;
13093         }
13094         return ret_ref;
13095 }
13096
13097 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
13098         LDKChainParameters orig_conv;
13099         orig_conv.inner = (void*)(orig & (~1));
13100         orig_conv.is_owned = false;
13101         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
13102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13104         uint64_t ret_ref = (uint64_t)ret_var.inner;
13105         if (ret_var.is_owned) {
13106                 ret_ref |= 1;
13107         }
13108         return ret_ref;
13109 }
13110
13111 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
13112         LDKChannelCounterparty this_obj_conv;
13113         this_obj_conv.inner = (void*)(this_obj & (~1));
13114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13115         ChannelCounterparty_free(this_obj_conv);
13116 }
13117
13118 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
13119         LDKChannelCounterparty this_ptr_conv;
13120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13121         this_ptr_conv.is_owned = false;
13122         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13123         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
13124         return ret_arr;
13125 }
13126
13127 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
13128         LDKChannelCounterparty this_ptr_conv;
13129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13130         this_ptr_conv.is_owned = false;
13131         LDKPublicKey val_ref;
13132         CHECK(*((uint32_t*)val) == 33);
13133         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13134         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
13135 }
13136
13137 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
13138         LDKChannelCounterparty this_ptr_conv;
13139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13140         this_ptr_conv.is_owned = false;
13141         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
13142         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13143         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13144         uint64_t ret_ref = (uint64_t)ret_var.inner;
13145         if (ret_var.is_owned) {
13146                 ret_ref |= 1;
13147         }
13148         return ret_ref;
13149 }
13150
13151 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
13152         LDKChannelCounterparty this_ptr_conv;
13153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13154         this_ptr_conv.is_owned = false;
13155         LDKInitFeatures val_conv;
13156         val_conv.inner = (void*)(val & (~1));
13157         val_conv.is_owned = (val & 1) || (val == 0);
13158         val_conv = InitFeatures_clone(&val_conv);
13159         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
13160 }
13161
13162 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
13163         LDKChannelCounterparty this_ptr_conv;
13164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13165         this_ptr_conv.is_owned = false;
13166         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
13167         return ret_val;
13168 }
13169
13170 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
13171         LDKChannelCounterparty this_ptr_conv;
13172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13173         this_ptr_conv.is_owned = false;
13174         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
13175 }
13176
13177 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
13178         LDKChannelCounterparty orig_conv;
13179         orig_conv.inner = (void*)(orig & (~1));
13180         orig_conv.is_owned = false;
13181         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
13182         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13183         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13184         uint64_t ret_ref = (uint64_t)ret_var.inner;
13185         if (ret_var.is_owned) {
13186                 ret_ref |= 1;
13187         }
13188         return ret_ref;
13189 }
13190
13191 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
13192         LDKChannelDetails this_obj_conv;
13193         this_obj_conv.inner = (void*)(this_obj & (~1));
13194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13195         ChannelDetails_free(this_obj_conv);
13196 }
13197
13198 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
13199         LDKChannelDetails this_ptr_conv;
13200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13201         this_ptr_conv.is_owned = false;
13202         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13203         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
13204         return ret_arr;
13205 }
13206
13207 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13208         LDKChannelDetails this_ptr_conv;
13209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13210         this_ptr_conv.is_owned = false;
13211         LDKThirtyTwoBytes val_ref;
13212         CHECK(*((uint32_t*)val) == 32);
13213         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13214         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
13215 }
13216
13217 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
13218         LDKChannelDetails this_ptr_conv;
13219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13220         this_ptr_conv.is_owned = false;
13221         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
13222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13224         uint64_t ret_ref = (uint64_t)ret_var.inner;
13225         if (ret_var.is_owned) {
13226                 ret_ref |= 1;
13227         }
13228         return ret_ref;
13229 }
13230
13231 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
13232         LDKChannelDetails this_ptr_conv;
13233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13234         this_ptr_conv.is_owned = false;
13235         LDKChannelCounterparty val_conv;
13236         val_conv.inner = (void*)(val & (~1));
13237         val_conv.is_owned = (val & 1) || (val == 0);
13238         val_conv = ChannelCounterparty_clone(&val_conv);
13239         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
13240 }
13241
13242 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
13243         LDKChannelDetails this_ptr_conv;
13244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13245         this_ptr_conv.is_owned = false;
13246         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
13247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13249         uint64_t ret_ref = (uint64_t)ret_var.inner;
13250         if (ret_var.is_owned) {
13251                 ret_ref |= 1;
13252         }
13253         return ret_ref;
13254 }
13255
13256 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
13257         LDKChannelDetails this_ptr_conv;
13258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13259         this_ptr_conv.is_owned = false;
13260         LDKOutPoint val_conv;
13261         val_conv.inner = (void*)(val & (~1));
13262         val_conv.is_owned = (val & 1) || (val == 0);
13263         val_conv = OutPoint_clone(&val_conv);
13264         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
13265 }
13266
13267 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
13268         LDKChannelDetails this_ptr_conv;
13269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13270         this_ptr_conv.is_owned = false;
13271         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13272         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
13273         uint64_t ret_ref = (uint64_t)ret_copy;
13274         return ret_ref;
13275 }
13276
13277 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
13278         LDKChannelDetails this_ptr_conv;
13279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13280         this_ptr_conv.is_owned = false;
13281         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13282         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
13283 }
13284
13285 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
13286         LDKChannelDetails this_ptr_conv;
13287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13288         this_ptr_conv.is_owned = false;
13289         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
13290         return ret_val;
13291 }
13292
13293 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13294         LDKChannelDetails this_ptr_conv;
13295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13296         this_ptr_conv.is_owned = false;
13297         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
13298 }
13299
13300 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
13301         LDKChannelDetails this_ptr_conv;
13302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13303         this_ptr_conv.is_owned = false;
13304         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13305         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
13306         uint64_t ret_ref = (uint64_t)ret_copy;
13307         return ret_ref;
13308 }
13309
13310 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
13311         LDKChannelDetails this_ptr_conv;
13312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13313         this_ptr_conv.is_owned = false;
13314         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13315         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
13316 }
13317
13318 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
13319         LDKChannelDetails this_ptr_conv;
13320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13321         this_ptr_conv.is_owned = false;
13322         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
13323         return ret_val;
13324 }
13325
13326 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
13327         LDKChannelDetails this_ptr_conv;
13328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13329         this_ptr_conv.is_owned = false;
13330         ChannelDetails_set_user_id(&this_ptr_conv, val);
13331 }
13332
13333 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
13334         LDKChannelDetails this_ptr_conv;
13335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13336         this_ptr_conv.is_owned = false;
13337         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
13338         return ret_val;
13339 }
13340
13341 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13342         LDKChannelDetails this_ptr_conv;
13343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13344         this_ptr_conv.is_owned = false;
13345         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
13346 }
13347
13348 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
13349         LDKChannelDetails this_ptr_conv;
13350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13351         this_ptr_conv.is_owned = false;
13352         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
13353         return ret_val;
13354 }
13355
13356 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13357         LDKChannelDetails this_ptr_conv;
13358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13359         this_ptr_conv.is_owned = false;
13360         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
13361 }
13362
13363 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
13364         LDKChannelDetails this_ptr_conv;
13365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13366         this_ptr_conv.is_owned = false;
13367         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13368         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
13369         uint64_t ret_ref = (uint64_t)ret_copy;
13370         return ret_ref;
13371 }
13372
13373 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
13374         LDKChannelDetails this_ptr_conv;
13375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13376         this_ptr_conv.is_owned = false;
13377         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
13378         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
13379 }
13380
13381 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
13382         LDKChannelDetails this_ptr_conv;
13383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13384         this_ptr_conv.is_owned = false;
13385         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13386         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
13387         uint64_t ret_ref = (uint64_t)ret_copy;
13388         return ret_ref;
13389 }
13390
13391 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
13392         LDKChannelDetails this_ptr_conv;
13393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13394         this_ptr_conv.is_owned = false;
13395         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
13396         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
13397 }
13398
13399 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
13400         LDKChannelDetails this_ptr_conv;
13401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13402         this_ptr_conv.is_owned = false;
13403         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
13404         return ret_val;
13405 }
13406
13407 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
13408         LDKChannelDetails this_ptr_conv;
13409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13410         this_ptr_conv.is_owned = false;
13411         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
13412 }
13413
13414 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
13415         LDKChannelDetails this_ptr_conv;
13416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13417         this_ptr_conv.is_owned = false;
13418         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
13419         return ret_val;
13420 }
13421
13422 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
13423         LDKChannelDetails this_ptr_conv;
13424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13425         this_ptr_conv.is_owned = false;
13426         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
13427 }
13428
13429 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
13430         LDKChannelDetails this_ptr_conv;
13431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13432         this_ptr_conv.is_owned = false;
13433         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
13434         return ret_val;
13435 }
13436
13437 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
13438         LDKChannelDetails this_ptr_conv;
13439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13440         this_ptr_conv.is_owned = false;
13441         ChannelDetails_set_is_usable(&this_ptr_conv, val);
13442 }
13443
13444 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
13445         LDKChannelDetails this_ptr_conv;
13446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13447         this_ptr_conv.is_owned = false;
13448         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
13449         return ret_val;
13450 }
13451
13452 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
13453         LDKChannelDetails this_ptr_conv;
13454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13455         this_ptr_conv.is_owned = false;
13456         ChannelDetails_set_is_public(&this_ptr_conv, val);
13457 }
13458
13459 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
13460         LDKThirtyTwoBytes channel_id_arg_ref;
13461         CHECK(*((uint32_t*)channel_id_arg) == 32);
13462         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13463         LDKChannelCounterparty counterparty_arg_conv;
13464         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
13465         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
13466         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
13467         LDKOutPoint funding_txo_arg_conv;
13468         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
13469         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
13470         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
13471         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
13472         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
13473         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
13474         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
13475         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
13476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13478         uint64_t ret_ref = (uint64_t)ret_var.inner;
13479         if (ret_var.is_owned) {
13480                 ret_ref |= 1;
13481         }
13482         return ret_ref;
13483 }
13484
13485 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
13486         LDKChannelDetails orig_conv;
13487         orig_conv.inner = (void*)(orig & (~1));
13488         orig_conv.is_owned = false;
13489         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
13490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13492         uint64_t ret_ref = (uint64_t)ret_var.inner;
13493         if (ret_var.is_owned) {
13494                 ret_ref |= 1;
13495         }
13496         return ret_ref;
13497 }
13498
13499 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
13500         if ((this_ptr & 1) != 0) return;
13501         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
13502         FREE((void*)this_ptr);
13503         PaymentSendFailure_free(this_ptr_conv);
13504 }
13505
13506 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
13507         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
13508         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
13509         *ret_copy = PaymentSendFailure_clone(orig_conv);
13510         uint64_t ret_ref = (uint64_t)ret_copy;
13511         return ret_ref;
13512 }
13513
13514 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) {
13515         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
13516         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13517         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13518         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13519         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13520         LDKUserConfig config_conv;
13521         config_conv.inner = (void*)(config & (~1));
13522         config_conv.is_owned = (config & 1) || (config == 0);
13523         config_conv = UserConfig_clone(&config_conv);
13524         LDKChainParameters params_conv;
13525         params_conv.inner = (void*)(params & (~1));
13526         params_conv.is_owned = (params & 1) || (params == 0);
13527         params_conv = ChainParameters_clone(&params_conv);
13528         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
13529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13531         uint64_t ret_ref = (uint64_t)ret_var.inner;
13532         if (ret_var.is_owned) {
13533                 ret_ref |= 1;
13534         }
13535         return ret_ref;
13536 }
13537
13538 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
13539         LDKChannelManager this_arg_conv;
13540         this_arg_conv.inner = (void*)(this_arg & (~1));
13541         this_arg_conv.is_owned = false;
13542         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13545         uint64_t ret_ref = (uint64_t)ret_var.inner;
13546         if (ret_var.is_owned) {
13547                 ret_ref |= 1;
13548         }
13549         return ret_ref;
13550 }
13551
13552 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) {
13553         LDKChannelManager this_arg_conv;
13554         this_arg_conv.inner = (void*)(this_arg & (~1));
13555         this_arg_conv.is_owned = false;
13556         LDKPublicKey their_network_key_ref;
13557         CHECK(*((uint32_t*)their_network_key) == 33);
13558         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
13559         LDKUserConfig override_config_conv;
13560         override_config_conv.inner = (void*)(override_config & (~1));
13561         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13562         override_config_conv = UserConfig_clone(&override_config_conv);
13563         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13564         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13565         return (uint64_t)ret_conv;
13566 }
13567
13568 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
13569         LDKChannelManager this_arg_conv;
13570         this_arg_conv.inner = (void*)(this_arg & (~1));
13571         this_arg_conv.is_owned = false;
13572         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13573         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13574         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13575         for (size_t q = 0; q < ret_var.datalen; q++) {
13576                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13577                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13578                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13579                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13580                 if (ret_conv_16_var.is_owned) {
13581                         ret_conv_16_ref |= 1;
13582                 }
13583                 ret_arr_ptr[q] = ret_conv_16_ref;
13584         }
13585         FREE(ret_var.data);
13586         return ret_arr;
13587 }
13588
13589 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
13590         LDKChannelManager this_arg_conv;
13591         this_arg_conv.inner = (void*)(this_arg & (~1));
13592         this_arg_conv.is_owned = false;
13593         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13594         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13595         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13596         for (size_t q = 0; q < ret_var.datalen; q++) {
13597                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13598                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13599                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13600                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13601                 if (ret_conv_16_var.is_owned) {
13602                         ret_conv_16_ref |= 1;
13603                 }
13604                 ret_arr_ptr[q] = ret_conv_16_ref;
13605         }
13606         FREE(ret_var.data);
13607         return ret_arr;
13608 }
13609
13610 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13611         LDKChannelManager this_arg_conv;
13612         this_arg_conv.inner = (void*)(this_arg & (~1));
13613         this_arg_conv.is_owned = false;
13614         unsigned char channel_id_arr[32];
13615         CHECK(*((uint32_t*)channel_id) == 32);
13616         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13617         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13618         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13619         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13620         return (uint64_t)ret_conv;
13621 }
13622
13623 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13624         LDKChannelManager this_arg_conv;
13625         this_arg_conv.inner = (void*)(this_arg & (~1));
13626         this_arg_conv.is_owned = false;
13627         unsigned char channel_id_arr[32];
13628         CHECK(*((uint32_t*)channel_id) == 32);
13629         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13630         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13631         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13632         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13633         return (uint64_t)ret_conv;
13634 }
13635
13636 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
13637         LDKChannelManager this_arg_conv;
13638         this_arg_conv.inner = (void*)(this_arg & (~1));
13639         this_arg_conv.is_owned = false;
13640         ChannelManager_force_close_all_channels(&this_arg_conv);
13641 }
13642
13643 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
13644         LDKChannelManager this_arg_conv;
13645         this_arg_conv.inner = (void*)(this_arg & (~1));
13646         this_arg_conv.is_owned = false;
13647         LDKRoute route_conv;
13648         route_conv.inner = (void*)(route & (~1));
13649         route_conv.is_owned = false;
13650         LDKThirtyTwoBytes payment_hash_ref;
13651         CHECK(*((uint32_t*)payment_hash) == 32);
13652         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13653         LDKThirtyTwoBytes payment_secret_ref;
13654         CHECK(*((uint32_t*)payment_secret) == 32);
13655         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
13656         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13657         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13658         return (uint64_t)ret_conv;
13659 }
13660
13661 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
13662         LDKChannelManager this_arg_conv;
13663         this_arg_conv.inner = (void*)(this_arg & (~1));
13664         this_arg_conv.is_owned = false;
13665         unsigned char temporary_channel_id_arr[32];
13666         CHECK(*((uint32_t*)temporary_channel_id) == 32);
13667         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
13668         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13669         LDKTransaction funding_transaction_ref;
13670         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
13671         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13672         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
13673         funding_transaction_ref.data_is_owned = true;
13674         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13675         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13676         return (uint64_t)ret_conv;
13677 }
13678
13679 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
13680         LDKChannelManager this_arg_conv;
13681         this_arg_conv.inner = (void*)(this_arg & (~1));
13682         this_arg_conv.is_owned = false;
13683         LDKThreeBytes rgb_ref;
13684         CHECK(*((uint32_t*)rgb) == 3);
13685         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
13686         LDKThirtyTwoBytes alias_ref;
13687         CHECK(*((uint32_t*)alias) == 32);
13688         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
13689         LDKCVec_NetAddressZ addresses_constr;
13690         addresses_constr.datalen = *((uint32_t*)addresses);
13691         if (addresses_constr.datalen > 0)
13692                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13693         else
13694                 addresses_constr.data = NULL;
13695         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
13696         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13697                 uint32_t addresses_conv_12 = addresses_vals[m];
13698                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13699                 addresses_constr.data[m] = addresses_conv_12_conv;
13700         }
13701         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13702 }
13703
13704 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
13705         LDKChannelManager this_arg_conv;
13706         this_arg_conv.inner = (void*)(this_arg & (~1));
13707         this_arg_conv.is_owned = false;
13708         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13709 }
13710
13711 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
13712         LDKChannelManager this_arg_conv;
13713         this_arg_conv.inner = (void*)(this_arg & (~1));
13714         this_arg_conv.is_owned = false;
13715         ChannelManager_timer_tick_occurred(&this_arg_conv);
13716 }
13717
13718 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
13719         LDKChannelManager this_arg_conv;
13720         this_arg_conv.inner = (void*)(this_arg & (~1));
13721         this_arg_conv.is_owned = false;
13722         unsigned char payment_hash_arr[32];
13723         CHECK(*((uint32_t*)payment_hash) == 32);
13724         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
13725         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13726         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
13727         return ret_val;
13728 }
13729
13730 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
13731         LDKChannelManager this_arg_conv;
13732         this_arg_conv.inner = (void*)(this_arg & (~1));
13733         this_arg_conv.is_owned = false;
13734         LDKThirtyTwoBytes payment_preimage_ref;
13735         CHECK(*((uint32_t*)payment_preimage) == 32);
13736         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13737         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
13738         return ret_val;
13739 }
13740
13741 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
13742         LDKChannelManager this_arg_conv;
13743         this_arg_conv.inner = (void*)(this_arg & (~1));
13744         this_arg_conv.is_owned = false;
13745         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13746         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
13747         return ret_arr;
13748 }
13749
13750 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
13751         LDKChannelManager this_arg_conv;
13752         this_arg_conv.inner = (void*)(this_arg & (~1));
13753         this_arg_conv.is_owned = false;
13754         LDKOutPoint funding_txo_conv;
13755         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13756         funding_txo_conv.is_owned = false;
13757         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13758 }
13759
13760 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
13761         LDKChannelManager this_arg_conv;
13762         this_arg_conv.inner = (void*)(this_arg & (~1));
13763         this_arg_conv.is_owned = false;
13764         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13765         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13766         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
13767         return (uint64_t)ret_ref;
13768 }
13769
13770 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment_for_hash(uint32_t this_arg, int8_tArray payment_hash, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
13771         LDKChannelManager this_arg_conv;
13772         this_arg_conv.inner = (void*)(this_arg & (~1));
13773         this_arg_conv.is_owned = false;
13774         LDKThirtyTwoBytes payment_hash_ref;
13775         CHECK(*((uint32_t*)payment_hash) == 32);
13776         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13777         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13778         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13779         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
13780         return (uint64_t)ret_conv;
13781 }
13782
13783 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
13784         LDKChannelManager this_arg_conv;
13785         this_arg_conv.inner = (void*)(this_arg & (~1));
13786         this_arg_conv.is_owned = false;
13787         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13788         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13789         return (uint64_t)ret;
13790 }
13791
13792 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
13793         LDKChannelManager this_arg_conv;
13794         this_arg_conv.inner = (void*)(this_arg & (~1));
13795         this_arg_conv.is_owned = false;
13796         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13797         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13798         return (uint64_t)ret;
13799 }
13800
13801 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
13802         LDKChannelManager this_arg_conv;
13803         this_arg_conv.inner = (void*)(this_arg & (~1));
13804         this_arg_conv.is_owned = false;
13805         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13806         *ret = ChannelManager_as_Listen(&this_arg_conv);
13807         return (uint64_t)ret;
13808 }
13809
13810 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
13811         LDKChannelManager this_arg_conv;
13812         this_arg_conv.inner = (void*)(this_arg & (~1));
13813         this_arg_conv.is_owned = false;
13814         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13815         *ret = ChannelManager_as_Confirm(&this_arg_conv);
13816         return (uint64_t)ret;
13817 }
13818
13819 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
13820         LDKChannelManager this_arg_conv;
13821         this_arg_conv.inner = (void*)(this_arg & (~1));
13822         this_arg_conv.is_owned = false;
13823         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13824         return ret_val;
13825 }
13826
13827 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
13828         LDKChannelManager this_arg_conv;
13829         this_arg_conv.inner = (void*)(this_arg & (~1));
13830         this_arg_conv.is_owned = false;
13831         ChannelManager_await_persistable_update(&this_arg_conv);
13832 }
13833
13834 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
13835         LDKChannelManager this_arg_conv;
13836         this_arg_conv.inner = (void*)(this_arg & (~1));
13837         this_arg_conv.is_owned = false;
13838         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
13839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13841         uint64_t ret_ref = (uint64_t)ret_var.inner;
13842         if (ret_var.is_owned) {
13843                 ret_ref |= 1;
13844         }
13845         return ret_ref;
13846 }
13847
13848 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
13849         LDKChannelManager this_arg_conv;
13850         this_arg_conv.inner = (void*)(this_arg & (~1));
13851         this_arg_conv.is_owned = false;
13852         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13853         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13854         return (uint64_t)ret;
13855 }
13856
13857 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
13858         LDKChannelManager obj_conv;
13859         obj_conv.inner = (void*)(obj & (~1));
13860         obj_conv.is_owned = false;
13861         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13862         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13863         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13864         CVec_u8Z_free(ret_var);
13865         return ret_arr;
13866 }
13867
13868 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
13869         LDKChannelManagerReadArgs this_obj_conv;
13870         this_obj_conv.inner = (void*)(this_obj & (~1));
13871         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13872         ChannelManagerReadArgs_free(this_obj_conv);
13873 }
13874
13875 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
13876         LDKChannelManagerReadArgs this_ptr_conv;
13877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13878         this_ptr_conv.is_owned = false;
13879         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13880         return ret_ret;
13881 }
13882
13883 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
13884         LDKChannelManagerReadArgs this_ptr_conv;
13885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13886         this_ptr_conv.is_owned = false;
13887         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13888         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13889 }
13890
13891 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
13892         LDKChannelManagerReadArgs this_ptr_conv;
13893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13894         this_ptr_conv.is_owned = false;
13895         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13896         return ret_ret;
13897 }
13898
13899 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
13900         LDKChannelManagerReadArgs this_ptr_conv;
13901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13902         this_ptr_conv.is_owned = false;
13903         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13904         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13905 }
13906
13907 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
13908         LDKChannelManagerReadArgs this_ptr_conv;
13909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13910         this_ptr_conv.is_owned = false;
13911         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13912         return ret_ret;
13913 }
13914
13915 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
13916         LDKChannelManagerReadArgs this_ptr_conv;
13917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13918         this_ptr_conv.is_owned = false;
13919         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13920         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13921 }
13922
13923 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
13924         LDKChannelManagerReadArgs this_ptr_conv;
13925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13926         this_ptr_conv.is_owned = false;
13927         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13928         return ret_ret;
13929 }
13930
13931 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
13932         LDKChannelManagerReadArgs this_ptr_conv;
13933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13934         this_ptr_conv.is_owned = false;
13935         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13936         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13937 }
13938
13939 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
13940         LDKChannelManagerReadArgs this_ptr_conv;
13941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13942         this_ptr_conv.is_owned = false;
13943         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13944         return ret_ret;
13945 }
13946
13947 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
13948         LDKChannelManagerReadArgs this_ptr_conv;
13949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13950         this_ptr_conv.is_owned = false;
13951         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13952         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13953 }
13954
13955 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
13956         LDKChannelManagerReadArgs this_ptr_conv;
13957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13958         this_ptr_conv.is_owned = false;
13959         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13962         uint64_t ret_ref = (uint64_t)ret_var.inner;
13963         if (ret_var.is_owned) {
13964                 ret_ref |= 1;
13965         }
13966         return ret_ref;
13967 }
13968
13969 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
13970         LDKChannelManagerReadArgs this_ptr_conv;
13971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13972         this_ptr_conv.is_owned = false;
13973         LDKUserConfig val_conv;
13974         val_conv.inner = (void*)(val & (~1));
13975         val_conv.is_owned = (val & 1) || (val == 0);
13976         val_conv = UserConfig_clone(&val_conv);
13977         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13978 }
13979
13980 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) {
13981         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13982         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13983         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13984         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13985         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13986         LDKUserConfig default_config_conv;
13987         default_config_conv.inner = (void*)(default_config & (~1));
13988         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13989         default_config_conv = UserConfig_clone(&default_config_conv);
13990         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13991         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
13992         if (channel_monitors_constr.datalen > 0)
13993                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13994         else
13995                 channel_monitors_constr.data = NULL;
13996         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
13997         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
13998                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
13999                 LDKChannelMonitor channel_monitors_conv_16_conv;
14000                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
14001                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
14002                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
14003         }
14004         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);
14005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14007         uint64_t ret_ref = (uint64_t)ret_var.inner;
14008         if (ret_var.is_owned) {
14009                 ret_ref |= 1;
14010         }
14011         return ret_ref;
14012 }
14013
14014 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
14015         LDKu8slice ser_ref;
14016         ser_ref.datalen = *((uint32_t*)ser);
14017         ser_ref.data = (int8_t*)(ser + 4);
14018         LDKChannelManagerReadArgs arg_conv;
14019         arg_conv.inner = (void*)(arg & (~1));
14020         arg_conv.is_owned = (arg & 1) || (arg == 0);
14021         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
14022         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14023         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
14024         return (uint64_t)ret_conv;
14025 }
14026
14027 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
14028         LDKDecodeError this_obj_conv;
14029         this_obj_conv.inner = (void*)(this_obj & (~1));
14030         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14031         DecodeError_free(this_obj_conv);
14032 }
14033
14034 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
14035         LDKDecodeError orig_conv;
14036         orig_conv.inner = (void*)(orig & (~1));
14037         orig_conv.is_owned = false;
14038         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
14039         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14040         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14041         uint64_t ret_ref = (uint64_t)ret_var.inner;
14042         if (ret_var.is_owned) {
14043                 ret_ref |= 1;
14044         }
14045         return ret_ref;
14046 }
14047
14048 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
14049         LDKInit this_obj_conv;
14050         this_obj_conv.inner = (void*)(this_obj & (~1));
14051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14052         Init_free(this_obj_conv);
14053 }
14054
14055 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
14056         LDKInit this_ptr_conv;
14057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14058         this_ptr_conv.is_owned = false;
14059         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
14060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14062         uint64_t ret_ref = (uint64_t)ret_var.inner;
14063         if (ret_var.is_owned) {
14064                 ret_ref |= 1;
14065         }
14066         return ret_ref;
14067 }
14068
14069 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
14070         LDKInit this_ptr_conv;
14071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14072         this_ptr_conv.is_owned = false;
14073         LDKInitFeatures val_conv;
14074         val_conv.inner = (void*)(val & (~1));
14075         val_conv.is_owned = (val & 1) || (val == 0);
14076         val_conv = InitFeatures_clone(&val_conv);
14077         Init_set_features(&this_ptr_conv, val_conv);
14078 }
14079
14080 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
14081         LDKInitFeatures features_arg_conv;
14082         features_arg_conv.inner = (void*)(features_arg & (~1));
14083         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
14084         features_arg_conv = InitFeatures_clone(&features_arg_conv);
14085         LDKInit ret_var = Init_new(features_arg_conv);
14086         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14087         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14088         uint64_t ret_ref = (uint64_t)ret_var.inner;
14089         if (ret_var.is_owned) {
14090                 ret_ref |= 1;
14091         }
14092         return ret_ref;
14093 }
14094
14095 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
14096         LDKInit orig_conv;
14097         orig_conv.inner = (void*)(orig & (~1));
14098         orig_conv.is_owned = false;
14099         LDKInit ret_var = Init_clone(&orig_conv);
14100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14102         uint64_t ret_ref = (uint64_t)ret_var.inner;
14103         if (ret_var.is_owned) {
14104                 ret_ref |= 1;
14105         }
14106         return ret_ref;
14107 }
14108
14109 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
14110         LDKErrorMessage this_obj_conv;
14111         this_obj_conv.inner = (void*)(this_obj & (~1));
14112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14113         ErrorMessage_free(this_obj_conv);
14114 }
14115
14116 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
14117         LDKErrorMessage this_ptr_conv;
14118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14119         this_ptr_conv.is_owned = false;
14120         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14121         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
14122         return ret_arr;
14123 }
14124
14125 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14126         LDKErrorMessage this_ptr_conv;
14127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14128         this_ptr_conv.is_owned = false;
14129         LDKThirtyTwoBytes val_ref;
14130         CHECK(*((uint32_t*)val) == 32);
14131         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14132         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
14133 }
14134
14135 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
14136         LDKErrorMessage this_ptr_conv;
14137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14138         this_ptr_conv.is_owned = false;
14139         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
14140         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
14141         return ret_conv;
14142 }
14143
14144 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
14145         LDKErrorMessage this_ptr_conv;
14146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14147         this_ptr_conv.is_owned = false;
14148         LDKStr val_conv = str_ref_to_owned_c(val);
14149         ErrorMessage_set_data(&this_ptr_conv, val_conv);
14150 }
14151
14152 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
14153         LDKThirtyTwoBytes channel_id_arg_ref;
14154         CHECK(*((uint32_t*)channel_id_arg) == 32);
14155         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14156         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
14157         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
14158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14160         uint64_t ret_ref = (uint64_t)ret_var.inner;
14161         if (ret_var.is_owned) {
14162                 ret_ref |= 1;
14163         }
14164         return ret_ref;
14165 }
14166
14167 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
14168         LDKErrorMessage orig_conv;
14169         orig_conv.inner = (void*)(orig & (~1));
14170         orig_conv.is_owned = false;
14171         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
14172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14174         uint64_t ret_ref = (uint64_t)ret_var.inner;
14175         if (ret_var.is_owned) {
14176                 ret_ref |= 1;
14177         }
14178         return ret_ref;
14179 }
14180
14181 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
14182         LDKPing this_obj_conv;
14183         this_obj_conv.inner = (void*)(this_obj & (~1));
14184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14185         Ping_free(this_obj_conv);
14186 }
14187
14188 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
14189         LDKPing this_ptr_conv;
14190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14191         this_ptr_conv.is_owned = false;
14192         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
14193         return ret_val;
14194 }
14195
14196 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
14197         LDKPing this_ptr_conv;
14198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14199         this_ptr_conv.is_owned = false;
14200         Ping_set_ponglen(&this_ptr_conv, val);
14201 }
14202
14203 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
14204         LDKPing this_ptr_conv;
14205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14206         this_ptr_conv.is_owned = false;
14207         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
14208         return ret_val;
14209 }
14210
14211 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
14212         LDKPing this_ptr_conv;
14213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14214         this_ptr_conv.is_owned = false;
14215         Ping_set_byteslen(&this_ptr_conv, val);
14216 }
14217
14218 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
14219         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
14220         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14221         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14222         uint64_t ret_ref = (uint64_t)ret_var.inner;
14223         if (ret_var.is_owned) {
14224                 ret_ref |= 1;
14225         }
14226         return ret_ref;
14227 }
14228
14229 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
14230         LDKPing orig_conv;
14231         orig_conv.inner = (void*)(orig & (~1));
14232         orig_conv.is_owned = false;
14233         LDKPing ret_var = Ping_clone(&orig_conv);
14234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14236         uint64_t ret_ref = (uint64_t)ret_var.inner;
14237         if (ret_var.is_owned) {
14238                 ret_ref |= 1;
14239         }
14240         return ret_ref;
14241 }
14242
14243 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
14244         LDKPong this_obj_conv;
14245         this_obj_conv.inner = (void*)(this_obj & (~1));
14246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14247         Pong_free(this_obj_conv);
14248 }
14249
14250 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
14251         LDKPong this_ptr_conv;
14252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14253         this_ptr_conv.is_owned = false;
14254         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
14255         return ret_val;
14256 }
14257
14258 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
14259         LDKPong this_ptr_conv;
14260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14261         this_ptr_conv.is_owned = false;
14262         Pong_set_byteslen(&this_ptr_conv, val);
14263 }
14264
14265 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
14266         LDKPong ret_var = Pong_new(byteslen_arg);
14267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14269         uint64_t ret_ref = (uint64_t)ret_var.inner;
14270         if (ret_var.is_owned) {
14271                 ret_ref |= 1;
14272         }
14273         return ret_ref;
14274 }
14275
14276 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
14277         LDKPong orig_conv;
14278         orig_conv.inner = (void*)(orig & (~1));
14279         orig_conv.is_owned = false;
14280         LDKPong ret_var = Pong_clone(&orig_conv);
14281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14283         uint64_t ret_ref = (uint64_t)ret_var.inner;
14284         if (ret_var.is_owned) {
14285                 ret_ref |= 1;
14286         }
14287         return ret_ref;
14288 }
14289
14290 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
14291         LDKOpenChannel this_obj_conv;
14292         this_obj_conv.inner = (void*)(this_obj & (~1));
14293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14294         OpenChannel_free(this_obj_conv);
14295 }
14296
14297 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
14298         LDKOpenChannel this_ptr_conv;
14299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14300         this_ptr_conv.is_owned = false;
14301         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14302         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
14303         return ret_arr;
14304 }
14305
14306 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14307         LDKOpenChannel this_ptr_conv;
14308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14309         this_ptr_conv.is_owned = false;
14310         LDKThirtyTwoBytes val_ref;
14311         CHECK(*((uint32_t*)val) == 32);
14312         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14313         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
14314 }
14315
14316 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
14317         LDKOpenChannel this_ptr_conv;
14318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14319         this_ptr_conv.is_owned = false;
14320         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14321         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14322         return ret_arr;
14323 }
14324
14325 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14326         LDKOpenChannel this_ptr_conv;
14327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14328         this_ptr_conv.is_owned = false;
14329         LDKThirtyTwoBytes val_ref;
14330         CHECK(*((uint32_t*)val) == 32);
14331         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14332         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14333 }
14334
14335 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
14336         LDKOpenChannel this_ptr_conv;
14337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14338         this_ptr_conv.is_owned = false;
14339         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
14340         return ret_val;
14341 }
14342
14343 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
14344         LDKOpenChannel this_ptr_conv;
14345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14346         this_ptr_conv.is_owned = false;
14347         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
14348 }
14349
14350 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
14351         LDKOpenChannel this_ptr_conv;
14352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14353         this_ptr_conv.is_owned = false;
14354         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
14355         return ret_val;
14356 }
14357
14358 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
14359         LDKOpenChannel this_ptr_conv;
14360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14361         this_ptr_conv.is_owned = false;
14362         OpenChannel_set_push_msat(&this_ptr_conv, val);
14363 }
14364
14365 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14366         LDKOpenChannel this_ptr_conv;
14367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14368         this_ptr_conv.is_owned = false;
14369         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
14370         return ret_val;
14371 }
14372
14373 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14374         LDKOpenChannel this_ptr_conv;
14375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14376         this_ptr_conv.is_owned = false;
14377         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14378 }
14379
14380 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14381         LDKOpenChannel this_ptr_conv;
14382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14383         this_ptr_conv.is_owned = false;
14384         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14385         return ret_val;
14386 }
14387
14388 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14389         LDKOpenChannel this_ptr_conv;
14390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14391         this_ptr_conv.is_owned = false;
14392         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14393 }
14394
14395 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14396         LDKOpenChannel this_ptr_conv;
14397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14398         this_ptr_conv.is_owned = false;
14399         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14400         return ret_val;
14401 }
14402
14403 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14404         LDKOpenChannel this_ptr_conv;
14405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14406         this_ptr_conv.is_owned = false;
14407         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14408 }
14409
14410 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14411         LDKOpenChannel this_ptr_conv;
14412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14413         this_ptr_conv.is_owned = false;
14414         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
14415         return ret_val;
14416 }
14417
14418 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14419         LDKOpenChannel this_ptr_conv;
14420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14421         this_ptr_conv.is_owned = false;
14422         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14423 }
14424
14425 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
14426         LDKOpenChannel this_ptr_conv;
14427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14428         this_ptr_conv.is_owned = false;
14429         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
14430         return ret_val;
14431 }
14432
14433 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
14434         LDKOpenChannel this_ptr_conv;
14435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14436         this_ptr_conv.is_owned = false;
14437         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
14438 }
14439
14440 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
14441         LDKOpenChannel this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
14445         return ret_val;
14446 }
14447
14448 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14449         LDKOpenChannel this_ptr_conv;
14450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14451         this_ptr_conv.is_owned = false;
14452         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
14453 }
14454
14455 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14456         LDKOpenChannel this_ptr_conv;
14457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14458         this_ptr_conv.is_owned = false;
14459         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
14460         return ret_val;
14461 }
14462
14463 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14464         LDKOpenChannel this_ptr_conv;
14465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14466         this_ptr_conv.is_owned = false;
14467         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14468 }
14469
14470 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
14471         LDKOpenChannel this_ptr_conv;
14472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14473         this_ptr_conv.is_owned = false;
14474         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14475         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14476         return ret_arr;
14477 }
14478
14479 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14480         LDKOpenChannel this_ptr_conv;
14481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14482         this_ptr_conv.is_owned = false;
14483         LDKPublicKey val_ref;
14484         CHECK(*((uint32_t*)val) == 33);
14485         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14486         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14487 }
14488
14489 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
14490         LDKOpenChannel this_ptr_conv;
14491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14492         this_ptr_conv.is_owned = false;
14493         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14494         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14495         return ret_arr;
14496 }
14497
14498 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14499         LDKOpenChannel this_ptr_conv;
14500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14501         this_ptr_conv.is_owned = false;
14502         LDKPublicKey val_ref;
14503         CHECK(*((uint32_t*)val) == 33);
14504         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14505         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14506 }
14507
14508 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
14509         LDKOpenChannel this_ptr_conv;
14510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14511         this_ptr_conv.is_owned = false;
14512         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14513         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14514         return ret_arr;
14515 }
14516
14517 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14518         LDKOpenChannel this_ptr_conv;
14519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14520         this_ptr_conv.is_owned = false;
14521         LDKPublicKey val_ref;
14522         CHECK(*((uint32_t*)val) == 33);
14523         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14524         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14525 }
14526
14527 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14528         LDKOpenChannel this_ptr_conv;
14529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14530         this_ptr_conv.is_owned = false;
14531         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14532         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14533         return ret_arr;
14534 }
14535
14536 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14537         LDKOpenChannel this_ptr_conv;
14538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14539         this_ptr_conv.is_owned = false;
14540         LDKPublicKey val_ref;
14541         CHECK(*((uint32_t*)val) == 33);
14542         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14543         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14544 }
14545
14546 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
14547         LDKOpenChannel this_ptr_conv;
14548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14549         this_ptr_conv.is_owned = false;
14550         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14551         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14552         return ret_arr;
14553 }
14554
14555 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14556         LDKOpenChannel this_ptr_conv;
14557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14558         this_ptr_conv.is_owned = false;
14559         LDKPublicKey val_ref;
14560         CHECK(*((uint32_t*)val) == 33);
14561         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14562         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14563 }
14564
14565 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14566         LDKOpenChannel this_ptr_conv;
14567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14568         this_ptr_conv.is_owned = false;
14569         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14570         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14571         return ret_arr;
14572 }
14573
14574 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14575         LDKOpenChannel this_ptr_conv;
14576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14577         this_ptr_conv.is_owned = false;
14578         LDKPublicKey val_ref;
14579         CHECK(*((uint32_t*)val) == 33);
14580         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14581         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14582 }
14583
14584 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
14585         LDKOpenChannel this_ptr_conv;
14586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14587         this_ptr_conv.is_owned = false;
14588         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14589         return ret_val;
14590 }
14591
14592 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
14593         LDKOpenChannel this_ptr_conv;
14594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14595         this_ptr_conv.is_owned = false;
14596         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14597 }
14598
14599 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
14600         LDKOpenChannel orig_conv;
14601         orig_conv.inner = (void*)(orig & (~1));
14602         orig_conv.is_owned = false;
14603         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14604         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14605         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14606         uint64_t ret_ref = (uint64_t)ret_var.inner;
14607         if (ret_var.is_owned) {
14608                 ret_ref |= 1;
14609         }
14610         return ret_ref;
14611 }
14612
14613 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
14614         LDKAcceptChannel this_obj_conv;
14615         this_obj_conv.inner = (void*)(this_obj & (~1));
14616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14617         AcceptChannel_free(this_obj_conv);
14618 }
14619
14620 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
14621         LDKAcceptChannel this_ptr_conv;
14622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14623         this_ptr_conv.is_owned = false;
14624         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14625         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14626         return ret_arr;
14627 }
14628
14629 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14630         LDKAcceptChannel this_ptr_conv;
14631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14632         this_ptr_conv.is_owned = false;
14633         LDKThirtyTwoBytes val_ref;
14634         CHECK(*((uint32_t*)val) == 32);
14635         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14636         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14637 }
14638
14639 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14640         LDKAcceptChannel this_ptr_conv;
14641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14642         this_ptr_conv.is_owned = false;
14643         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14644         return ret_val;
14645 }
14646
14647 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14648         LDKAcceptChannel this_ptr_conv;
14649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14650         this_ptr_conv.is_owned = false;
14651         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14652 }
14653
14654 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14655         LDKAcceptChannel this_ptr_conv;
14656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14657         this_ptr_conv.is_owned = false;
14658         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14659         return ret_val;
14660 }
14661
14662 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14663         LDKAcceptChannel this_ptr_conv;
14664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14665         this_ptr_conv.is_owned = false;
14666         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14667 }
14668
14669 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14670         LDKAcceptChannel this_ptr_conv;
14671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14672         this_ptr_conv.is_owned = false;
14673         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14674         return ret_val;
14675 }
14676
14677 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14678         LDKAcceptChannel this_ptr_conv;
14679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14680         this_ptr_conv.is_owned = false;
14681         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14682 }
14683
14684 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14685         LDKAcceptChannel this_ptr_conv;
14686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14687         this_ptr_conv.is_owned = false;
14688         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14689         return ret_val;
14690 }
14691
14692 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14693         LDKAcceptChannel this_ptr_conv;
14694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14695         this_ptr_conv.is_owned = false;
14696         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14697 }
14698
14699 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
14700         LDKAcceptChannel this_ptr_conv;
14701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14702         this_ptr_conv.is_owned = false;
14703         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14704         return ret_val;
14705 }
14706
14707 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
14708         LDKAcceptChannel this_ptr_conv;
14709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14710         this_ptr_conv.is_owned = false;
14711         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14712 }
14713
14714 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
14715         LDKAcceptChannel this_ptr_conv;
14716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14717         this_ptr_conv.is_owned = false;
14718         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14719         return ret_val;
14720 }
14721
14722 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14723         LDKAcceptChannel this_ptr_conv;
14724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14725         this_ptr_conv.is_owned = false;
14726         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14727 }
14728
14729 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14730         LDKAcceptChannel this_ptr_conv;
14731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14732         this_ptr_conv.is_owned = false;
14733         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14734         return ret_val;
14735 }
14736
14737 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14738         LDKAcceptChannel this_ptr_conv;
14739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14740         this_ptr_conv.is_owned = false;
14741         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14742 }
14743
14744 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
14745         LDKAcceptChannel this_ptr_conv;
14746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14747         this_ptr_conv.is_owned = false;
14748         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14749         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14750         return ret_arr;
14751 }
14752
14753 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14754         LDKAcceptChannel this_ptr_conv;
14755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14756         this_ptr_conv.is_owned = false;
14757         LDKPublicKey val_ref;
14758         CHECK(*((uint32_t*)val) == 33);
14759         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14760         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14761 }
14762
14763 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
14764         LDKAcceptChannel this_ptr_conv;
14765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14766         this_ptr_conv.is_owned = false;
14767         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14768         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14769         return ret_arr;
14770 }
14771
14772 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14773         LDKAcceptChannel this_ptr_conv;
14774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14775         this_ptr_conv.is_owned = false;
14776         LDKPublicKey val_ref;
14777         CHECK(*((uint32_t*)val) == 33);
14778         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14779         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14780 }
14781
14782 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
14783         LDKAcceptChannel this_ptr_conv;
14784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14785         this_ptr_conv.is_owned = false;
14786         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14787         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14788         return ret_arr;
14789 }
14790
14791 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14792         LDKAcceptChannel this_ptr_conv;
14793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14794         this_ptr_conv.is_owned = false;
14795         LDKPublicKey val_ref;
14796         CHECK(*((uint32_t*)val) == 33);
14797         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14798         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14799 }
14800
14801 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14802         LDKAcceptChannel this_ptr_conv;
14803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14804         this_ptr_conv.is_owned = false;
14805         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14806         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14807         return ret_arr;
14808 }
14809
14810 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14811         LDKAcceptChannel this_ptr_conv;
14812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14813         this_ptr_conv.is_owned = false;
14814         LDKPublicKey val_ref;
14815         CHECK(*((uint32_t*)val) == 33);
14816         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14817         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14818 }
14819
14820 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
14821         LDKAcceptChannel this_ptr_conv;
14822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14823         this_ptr_conv.is_owned = false;
14824         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14825         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14826         return ret_arr;
14827 }
14828
14829 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14830         LDKAcceptChannel this_ptr_conv;
14831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14832         this_ptr_conv.is_owned = false;
14833         LDKPublicKey val_ref;
14834         CHECK(*((uint32_t*)val) == 33);
14835         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14836         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14837 }
14838
14839 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14840         LDKAcceptChannel this_ptr_conv;
14841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14842         this_ptr_conv.is_owned = false;
14843         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14844         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14845         return ret_arr;
14846 }
14847
14848 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14849         LDKAcceptChannel this_ptr_conv;
14850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14851         this_ptr_conv.is_owned = false;
14852         LDKPublicKey val_ref;
14853         CHECK(*((uint32_t*)val) == 33);
14854         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14855         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14856 }
14857
14858 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
14859         LDKAcceptChannel orig_conv;
14860         orig_conv.inner = (void*)(orig & (~1));
14861         orig_conv.is_owned = false;
14862         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14865         uint64_t ret_ref = (uint64_t)ret_var.inner;
14866         if (ret_var.is_owned) {
14867                 ret_ref |= 1;
14868         }
14869         return ret_ref;
14870 }
14871
14872 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
14873         LDKFundingCreated this_obj_conv;
14874         this_obj_conv.inner = (void*)(this_obj & (~1));
14875         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14876         FundingCreated_free(this_obj_conv);
14877 }
14878
14879 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
14880         LDKFundingCreated this_ptr_conv;
14881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14882         this_ptr_conv.is_owned = false;
14883         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14884         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
14885         return ret_arr;
14886 }
14887
14888 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14889         LDKFundingCreated this_ptr_conv;
14890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14891         this_ptr_conv.is_owned = false;
14892         LDKThirtyTwoBytes val_ref;
14893         CHECK(*((uint32_t*)val) == 32);
14894         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14895         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14896 }
14897
14898 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
14899         LDKFundingCreated this_ptr_conv;
14900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14901         this_ptr_conv.is_owned = false;
14902         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14903         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
14904         return ret_arr;
14905 }
14906
14907 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
14908         LDKFundingCreated this_ptr_conv;
14909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14910         this_ptr_conv.is_owned = false;
14911         LDKThirtyTwoBytes val_ref;
14912         CHECK(*((uint32_t*)val) == 32);
14913         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14914         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14915 }
14916
14917 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
14918         LDKFundingCreated this_ptr_conv;
14919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14920         this_ptr_conv.is_owned = false;
14921         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14922         return ret_val;
14923 }
14924
14925 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
14926         LDKFundingCreated this_ptr_conv;
14927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14928         this_ptr_conv.is_owned = false;
14929         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14930 }
14931
14932 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
14933         LDKFundingCreated this_ptr_conv;
14934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14935         this_ptr_conv.is_owned = false;
14936         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14937         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
14938         return ret_arr;
14939 }
14940
14941 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
14942         LDKFundingCreated this_ptr_conv;
14943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14944         this_ptr_conv.is_owned = false;
14945         LDKSignature val_ref;
14946         CHECK(*((uint32_t*)val) == 64);
14947         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14948         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14949 }
14950
14951 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) {
14952         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14953         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
14954         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
14955         LDKThirtyTwoBytes funding_txid_arg_ref;
14956         CHECK(*((uint32_t*)funding_txid_arg) == 32);
14957         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
14958         LDKSignature signature_arg_ref;
14959         CHECK(*((uint32_t*)signature_arg) == 64);
14960         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14961         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14964         uint64_t ret_ref = (uint64_t)ret_var.inner;
14965         if (ret_var.is_owned) {
14966                 ret_ref |= 1;
14967         }
14968         return ret_ref;
14969 }
14970
14971 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
14972         LDKFundingCreated orig_conv;
14973         orig_conv.inner = (void*)(orig & (~1));
14974         orig_conv.is_owned = false;
14975         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14976         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14977         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14978         uint64_t ret_ref = (uint64_t)ret_var.inner;
14979         if (ret_var.is_owned) {
14980                 ret_ref |= 1;
14981         }
14982         return ret_ref;
14983 }
14984
14985 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
14986         LDKFundingSigned this_obj_conv;
14987         this_obj_conv.inner = (void*)(this_obj & (~1));
14988         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14989         FundingSigned_free(this_obj_conv);
14990 }
14991
14992 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
14993         LDKFundingSigned this_ptr_conv;
14994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14995         this_ptr_conv.is_owned = false;
14996         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14997         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
14998         return ret_arr;
14999 }
15000
15001 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15002         LDKFundingSigned this_ptr_conv;
15003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15004         this_ptr_conv.is_owned = false;
15005         LDKThirtyTwoBytes val_ref;
15006         CHECK(*((uint32_t*)val) == 32);
15007         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15008         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
15009 }
15010
15011 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
15012         LDKFundingSigned this_ptr_conv;
15013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15014         this_ptr_conv.is_owned = false;
15015         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15016         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15017         return ret_arr;
15018 }
15019
15020 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15021         LDKFundingSigned this_ptr_conv;
15022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15023         this_ptr_conv.is_owned = false;
15024         LDKSignature val_ref;
15025         CHECK(*((uint32_t*)val) == 64);
15026         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15027         FundingSigned_set_signature(&this_ptr_conv, val_ref);
15028 }
15029
15030 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
15031         LDKThirtyTwoBytes channel_id_arg_ref;
15032         CHECK(*((uint32_t*)channel_id_arg) == 32);
15033         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15034         LDKSignature signature_arg_ref;
15035         CHECK(*((uint32_t*)signature_arg) == 64);
15036         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15037         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
15038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15040         uint64_t ret_ref = (uint64_t)ret_var.inner;
15041         if (ret_var.is_owned) {
15042                 ret_ref |= 1;
15043         }
15044         return ret_ref;
15045 }
15046
15047 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
15048         LDKFundingSigned orig_conv;
15049         orig_conv.inner = (void*)(orig & (~1));
15050         orig_conv.is_owned = false;
15051         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
15052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15054         uint64_t ret_ref = (uint64_t)ret_var.inner;
15055         if (ret_var.is_owned) {
15056                 ret_ref |= 1;
15057         }
15058         return ret_ref;
15059 }
15060
15061 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
15062         LDKFundingLocked this_obj_conv;
15063         this_obj_conv.inner = (void*)(this_obj & (~1));
15064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15065         FundingLocked_free(this_obj_conv);
15066 }
15067
15068 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
15069         LDKFundingLocked this_ptr_conv;
15070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15071         this_ptr_conv.is_owned = false;
15072         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15073         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
15074         return ret_arr;
15075 }
15076
15077 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15078         LDKFundingLocked this_ptr_conv;
15079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15080         this_ptr_conv.is_owned = false;
15081         LDKThirtyTwoBytes val_ref;
15082         CHECK(*((uint32_t*)val) == 32);
15083         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15084         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
15085 }
15086
15087 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
15088         LDKFundingLocked this_ptr_conv;
15089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15090         this_ptr_conv.is_owned = false;
15091         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15092         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15093         return ret_arr;
15094 }
15095
15096 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15097         LDKFundingLocked this_ptr_conv;
15098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15099         this_ptr_conv.is_owned = false;
15100         LDKPublicKey val_ref;
15101         CHECK(*((uint32_t*)val) == 33);
15102         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15103         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15104 }
15105
15106 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
15107         LDKThirtyTwoBytes channel_id_arg_ref;
15108         CHECK(*((uint32_t*)channel_id_arg) == 32);
15109         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15110         LDKPublicKey next_per_commitment_point_arg_ref;
15111         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15112         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15113         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
15114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15116         uint64_t ret_ref = (uint64_t)ret_var.inner;
15117         if (ret_var.is_owned) {
15118                 ret_ref |= 1;
15119         }
15120         return ret_ref;
15121 }
15122
15123 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
15124         LDKFundingLocked orig_conv;
15125         orig_conv.inner = (void*)(orig & (~1));
15126         orig_conv.is_owned = false;
15127         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
15128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15130         uint64_t ret_ref = (uint64_t)ret_var.inner;
15131         if (ret_var.is_owned) {
15132                 ret_ref |= 1;
15133         }
15134         return ret_ref;
15135 }
15136
15137 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
15138         LDKShutdown this_obj_conv;
15139         this_obj_conv.inner = (void*)(this_obj & (~1));
15140         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15141         Shutdown_free(this_obj_conv);
15142 }
15143
15144 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
15145         LDKShutdown this_ptr_conv;
15146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15147         this_ptr_conv.is_owned = false;
15148         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15149         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
15150         return ret_arr;
15151 }
15152
15153 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15154         LDKShutdown this_ptr_conv;
15155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15156         this_ptr_conv.is_owned = false;
15157         LDKThirtyTwoBytes val_ref;
15158         CHECK(*((uint32_t*)val) == 32);
15159         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15160         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
15161 }
15162
15163 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
15164         LDKShutdown this_ptr_conv;
15165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15166         this_ptr_conv.is_owned = false;
15167         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
15168         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15169         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15170         return ret_arr;
15171 }
15172
15173 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
15174         LDKShutdown this_ptr_conv;
15175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15176         this_ptr_conv.is_owned = false;
15177         LDKCVec_u8Z val_ref;
15178         val_ref.datalen = *((uint32_t*)val);
15179         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
15180         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
15181         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
15182 }
15183
15184 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
15185         LDKThirtyTwoBytes channel_id_arg_ref;
15186         CHECK(*((uint32_t*)channel_id_arg) == 32);
15187         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15188         LDKCVec_u8Z scriptpubkey_arg_ref;
15189         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
15190         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
15191         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
15192         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
15193         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15194         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15195         uint64_t ret_ref = (uint64_t)ret_var.inner;
15196         if (ret_var.is_owned) {
15197                 ret_ref |= 1;
15198         }
15199         return ret_ref;
15200 }
15201
15202 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
15203         LDKShutdown orig_conv;
15204         orig_conv.inner = (void*)(orig & (~1));
15205         orig_conv.is_owned = false;
15206         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
15207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15209         uint64_t ret_ref = (uint64_t)ret_var.inner;
15210         if (ret_var.is_owned) {
15211                 ret_ref |= 1;
15212         }
15213         return ret_ref;
15214 }
15215
15216 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
15217         LDKClosingSigned this_obj_conv;
15218         this_obj_conv.inner = (void*)(this_obj & (~1));
15219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15220         ClosingSigned_free(this_obj_conv);
15221 }
15222
15223 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
15224         LDKClosingSigned this_ptr_conv;
15225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15226         this_ptr_conv.is_owned = false;
15227         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15228         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
15229         return ret_arr;
15230 }
15231
15232 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15233         LDKClosingSigned this_ptr_conv;
15234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15235         this_ptr_conv.is_owned = false;
15236         LDKThirtyTwoBytes val_ref;
15237         CHECK(*((uint32_t*)val) == 32);
15238         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15239         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
15240 }
15241
15242 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
15243         LDKClosingSigned this_ptr_conv;
15244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15245         this_ptr_conv.is_owned = false;
15246         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
15247         return ret_val;
15248 }
15249
15250 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
15251         LDKClosingSigned this_ptr_conv;
15252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15253         this_ptr_conv.is_owned = false;
15254         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
15255 }
15256
15257 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
15258         LDKClosingSigned this_ptr_conv;
15259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15260         this_ptr_conv.is_owned = false;
15261         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15262         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15263         return ret_arr;
15264 }
15265
15266 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15267         LDKClosingSigned this_ptr_conv;
15268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15269         this_ptr_conv.is_owned = false;
15270         LDKSignature val_ref;
15271         CHECK(*((uint32_t*)val) == 64);
15272         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15273         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
15274 }
15275
15276 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
15277         LDKThirtyTwoBytes channel_id_arg_ref;
15278         CHECK(*((uint32_t*)channel_id_arg) == 32);
15279         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15280         LDKSignature signature_arg_ref;
15281         CHECK(*((uint32_t*)signature_arg) == 64);
15282         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15283         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
15284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15286         uint64_t ret_ref = (uint64_t)ret_var.inner;
15287         if (ret_var.is_owned) {
15288                 ret_ref |= 1;
15289         }
15290         return ret_ref;
15291 }
15292
15293 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
15294         LDKClosingSigned orig_conv;
15295         orig_conv.inner = (void*)(orig & (~1));
15296         orig_conv.is_owned = false;
15297         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
15298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15300         uint64_t ret_ref = (uint64_t)ret_var.inner;
15301         if (ret_var.is_owned) {
15302                 ret_ref |= 1;
15303         }
15304         return ret_ref;
15305 }
15306
15307 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
15308         LDKUpdateAddHTLC this_obj_conv;
15309         this_obj_conv.inner = (void*)(this_obj & (~1));
15310         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15311         UpdateAddHTLC_free(this_obj_conv);
15312 }
15313
15314 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
15315         LDKUpdateAddHTLC this_ptr_conv;
15316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15317         this_ptr_conv.is_owned = false;
15318         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15319         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
15320         return ret_arr;
15321 }
15322
15323 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15324         LDKUpdateAddHTLC this_ptr_conv;
15325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326         this_ptr_conv.is_owned = false;
15327         LDKThirtyTwoBytes val_ref;
15328         CHECK(*((uint32_t*)val) == 32);
15329         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15330         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
15331 }
15332
15333 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
15334         LDKUpdateAddHTLC this_ptr_conv;
15335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15336         this_ptr_conv.is_owned = false;
15337         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
15338         return ret_val;
15339 }
15340
15341 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15342         LDKUpdateAddHTLC this_ptr_conv;
15343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15344         this_ptr_conv.is_owned = false;
15345         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
15346 }
15347
15348 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
15349         LDKUpdateAddHTLC this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
15353         return ret_val;
15354 }
15355
15356 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
15357         LDKUpdateAddHTLC this_ptr_conv;
15358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15359         this_ptr_conv.is_owned = false;
15360         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
15361 }
15362
15363 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
15364         LDKUpdateAddHTLC this_ptr_conv;
15365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15366         this_ptr_conv.is_owned = false;
15367         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15368         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
15369         return ret_arr;
15370 }
15371
15372 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
15373         LDKUpdateAddHTLC this_ptr_conv;
15374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15375         this_ptr_conv.is_owned = false;
15376         LDKThirtyTwoBytes val_ref;
15377         CHECK(*((uint32_t*)val) == 32);
15378         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15379         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
15380 }
15381
15382 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
15383         LDKUpdateAddHTLC this_ptr_conv;
15384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15385         this_ptr_conv.is_owned = false;
15386         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
15387         return ret_val;
15388 }
15389
15390 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
15391         LDKUpdateAddHTLC this_ptr_conv;
15392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15393         this_ptr_conv.is_owned = false;
15394         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
15395 }
15396
15397 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
15398         LDKUpdateAddHTLC orig_conv;
15399         orig_conv.inner = (void*)(orig & (~1));
15400         orig_conv.is_owned = false;
15401         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
15402         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15403         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15404         uint64_t ret_ref = (uint64_t)ret_var.inner;
15405         if (ret_var.is_owned) {
15406                 ret_ref |= 1;
15407         }
15408         return ret_ref;
15409 }
15410
15411 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
15412         LDKUpdateFulfillHTLC this_obj_conv;
15413         this_obj_conv.inner = (void*)(this_obj & (~1));
15414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15415         UpdateFulfillHTLC_free(this_obj_conv);
15416 }
15417
15418 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
15419         LDKUpdateFulfillHTLC this_ptr_conv;
15420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15421         this_ptr_conv.is_owned = false;
15422         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15423         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
15424         return ret_arr;
15425 }
15426
15427 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15428         LDKUpdateFulfillHTLC this_ptr_conv;
15429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15430         this_ptr_conv.is_owned = false;
15431         LDKThirtyTwoBytes val_ref;
15432         CHECK(*((uint32_t*)val) == 32);
15433         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15434         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
15435 }
15436
15437 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
15438         LDKUpdateFulfillHTLC this_ptr_conv;
15439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15440         this_ptr_conv.is_owned = false;
15441         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
15442         return ret_val;
15443 }
15444
15445 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15446         LDKUpdateFulfillHTLC this_ptr_conv;
15447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15448         this_ptr_conv.is_owned = false;
15449         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
15450 }
15451
15452 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
15453         LDKUpdateFulfillHTLC this_ptr_conv;
15454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15455         this_ptr_conv.is_owned = false;
15456         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15457         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
15458         return ret_arr;
15459 }
15460
15461 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
15462         LDKUpdateFulfillHTLC this_ptr_conv;
15463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15464         this_ptr_conv.is_owned = false;
15465         LDKThirtyTwoBytes val_ref;
15466         CHECK(*((uint32_t*)val) == 32);
15467         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15468         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15469 }
15470
15471 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
15472         LDKThirtyTwoBytes channel_id_arg_ref;
15473         CHECK(*((uint32_t*)channel_id_arg) == 32);
15474         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15475         LDKThirtyTwoBytes payment_preimage_arg_ref;
15476         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
15477         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
15478         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15481         uint64_t ret_ref = (uint64_t)ret_var.inner;
15482         if (ret_var.is_owned) {
15483                 ret_ref |= 1;
15484         }
15485         return ret_ref;
15486 }
15487
15488 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
15489         LDKUpdateFulfillHTLC orig_conv;
15490         orig_conv.inner = (void*)(orig & (~1));
15491         orig_conv.is_owned = false;
15492         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15495         uint64_t ret_ref = (uint64_t)ret_var.inner;
15496         if (ret_var.is_owned) {
15497                 ret_ref |= 1;
15498         }
15499         return ret_ref;
15500 }
15501
15502 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
15503         LDKUpdateFailHTLC this_obj_conv;
15504         this_obj_conv.inner = (void*)(this_obj & (~1));
15505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15506         UpdateFailHTLC_free(this_obj_conv);
15507 }
15508
15509 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
15510         LDKUpdateFailHTLC this_ptr_conv;
15511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15512         this_ptr_conv.is_owned = false;
15513         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15514         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
15515         return ret_arr;
15516 }
15517
15518 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15519         LDKUpdateFailHTLC this_ptr_conv;
15520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15521         this_ptr_conv.is_owned = false;
15522         LDKThirtyTwoBytes val_ref;
15523         CHECK(*((uint32_t*)val) == 32);
15524         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15525         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15526 }
15527
15528 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
15529         LDKUpdateFailHTLC this_ptr_conv;
15530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15531         this_ptr_conv.is_owned = false;
15532         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15533         return ret_val;
15534 }
15535
15536 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15537         LDKUpdateFailHTLC this_ptr_conv;
15538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15539         this_ptr_conv.is_owned = false;
15540         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15541 }
15542
15543 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
15544         LDKUpdateFailHTLC orig_conv;
15545         orig_conv.inner = (void*)(orig & (~1));
15546         orig_conv.is_owned = false;
15547         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15550         uint64_t ret_ref = (uint64_t)ret_var.inner;
15551         if (ret_var.is_owned) {
15552                 ret_ref |= 1;
15553         }
15554         return ret_ref;
15555 }
15556
15557 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
15558         LDKUpdateFailMalformedHTLC this_obj_conv;
15559         this_obj_conv.inner = (void*)(this_obj & (~1));
15560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15561         UpdateFailMalformedHTLC_free(this_obj_conv);
15562 }
15563
15564 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
15565         LDKUpdateFailMalformedHTLC this_ptr_conv;
15566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15567         this_ptr_conv.is_owned = false;
15568         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15569         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
15570         return ret_arr;
15571 }
15572
15573 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15574         LDKUpdateFailMalformedHTLC this_ptr_conv;
15575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15576         this_ptr_conv.is_owned = false;
15577         LDKThirtyTwoBytes val_ref;
15578         CHECK(*((uint32_t*)val) == 32);
15579         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15580         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15581 }
15582
15583 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
15584         LDKUpdateFailMalformedHTLC this_ptr_conv;
15585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15586         this_ptr_conv.is_owned = false;
15587         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15588         return ret_val;
15589 }
15590
15591 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15592         LDKUpdateFailMalformedHTLC this_ptr_conv;
15593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15594         this_ptr_conv.is_owned = false;
15595         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15596 }
15597
15598 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
15599         LDKUpdateFailMalformedHTLC this_ptr_conv;
15600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15601         this_ptr_conv.is_owned = false;
15602         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15603         return ret_val;
15604 }
15605
15606 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
15607         LDKUpdateFailMalformedHTLC this_ptr_conv;
15608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15609         this_ptr_conv.is_owned = false;
15610         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15611 }
15612
15613 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
15614         LDKUpdateFailMalformedHTLC orig_conv;
15615         orig_conv.inner = (void*)(orig & (~1));
15616         orig_conv.is_owned = false;
15617         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15620         uint64_t ret_ref = (uint64_t)ret_var.inner;
15621         if (ret_var.is_owned) {
15622                 ret_ref |= 1;
15623         }
15624         return ret_ref;
15625 }
15626
15627 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
15628         LDKCommitmentSigned this_obj_conv;
15629         this_obj_conv.inner = (void*)(this_obj & (~1));
15630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15631         CommitmentSigned_free(this_obj_conv);
15632 }
15633
15634 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
15635         LDKCommitmentSigned this_ptr_conv;
15636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15637         this_ptr_conv.is_owned = false;
15638         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15639         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
15640         return ret_arr;
15641 }
15642
15643 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15644         LDKCommitmentSigned this_ptr_conv;
15645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15646         this_ptr_conv.is_owned = false;
15647         LDKThirtyTwoBytes val_ref;
15648         CHECK(*((uint32_t*)val) == 32);
15649         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15650         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15651 }
15652
15653 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
15654         LDKCommitmentSigned this_ptr_conv;
15655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15656         this_ptr_conv.is_owned = false;
15657         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15658         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
15659         return ret_arr;
15660 }
15661
15662 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15663         LDKCommitmentSigned this_ptr_conv;
15664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15665         this_ptr_conv.is_owned = false;
15666         LDKSignature val_ref;
15667         CHECK(*((uint32_t*)val) == 64);
15668         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15669         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15670 }
15671
15672 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
15673         LDKCommitmentSigned this_ptr_conv;
15674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15675         this_ptr_conv.is_owned = false;
15676         LDKCVec_SignatureZ val_constr;
15677         val_constr.datalen = *((uint32_t*)val);
15678         if (val_constr.datalen > 0)
15679                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15680         else
15681                 val_constr.data = NULL;
15682         int8_tArray* val_vals = (int8_tArray*)(val + 4);
15683         for (size_t m = 0; m < val_constr.datalen; m++) {
15684                 int8_tArray val_conv_12 = val_vals[m];
15685                 LDKSignature val_conv_12_ref;
15686                 CHECK(*((uint32_t*)val_conv_12) == 64);
15687                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
15688                 val_constr.data[m] = val_conv_12_ref;
15689         }
15690         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15691 }
15692
15693 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
15694         LDKThirtyTwoBytes channel_id_arg_ref;
15695         CHECK(*((uint32_t*)channel_id_arg) == 32);
15696         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15697         LDKSignature signature_arg_ref;
15698         CHECK(*((uint32_t*)signature_arg) == 64);
15699         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15700         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15701         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
15702         if (htlc_signatures_arg_constr.datalen > 0)
15703                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15704         else
15705                 htlc_signatures_arg_constr.data = NULL;
15706         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
15707         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
15708                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
15709                 LDKSignature htlc_signatures_arg_conv_12_ref;
15710                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
15711                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
15712                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
15713         }
15714         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15717         uint64_t ret_ref = (uint64_t)ret_var.inner;
15718         if (ret_var.is_owned) {
15719                 ret_ref |= 1;
15720         }
15721         return ret_ref;
15722 }
15723
15724 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
15725         LDKCommitmentSigned orig_conv;
15726         orig_conv.inner = (void*)(orig & (~1));
15727         orig_conv.is_owned = false;
15728         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15731         uint64_t ret_ref = (uint64_t)ret_var.inner;
15732         if (ret_var.is_owned) {
15733                 ret_ref |= 1;
15734         }
15735         return ret_ref;
15736 }
15737
15738 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
15739         LDKRevokeAndACK this_obj_conv;
15740         this_obj_conv.inner = (void*)(this_obj & (~1));
15741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15742         RevokeAndACK_free(this_obj_conv);
15743 }
15744
15745 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
15746         LDKRevokeAndACK this_ptr_conv;
15747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15748         this_ptr_conv.is_owned = false;
15749         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15750         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
15751         return ret_arr;
15752 }
15753
15754 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15755         LDKRevokeAndACK this_ptr_conv;
15756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15757         this_ptr_conv.is_owned = false;
15758         LDKThirtyTwoBytes val_ref;
15759         CHECK(*((uint32_t*)val) == 32);
15760         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15761         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15762 }
15763
15764 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
15765         LDKRevokeAndACK this_ptr_conv;
15766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15767         this_ptr_conv.is_owned = false;
15768         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15769         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
15770         return ret_arr;
15771 }
15772
15773 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15774         LDKRevokeAndACK this_ptr_conv;
15775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15776         this_ptr_conv.is_owned = false;
15777         LDKThirtyTwoBytes val_ref;
15778         CHECK(*((uint32_t*)val) == 32);
15779         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15780         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15781 }
15782
15783 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
15784         LDKRevokeAndACK this_ptr_conv;
15785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15786         this_ptr_conv.is_owned = false;
15787         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15788         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15789         return ret_arr;
15790 }
15791
15792 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15793         LDKRevokeAndACK this_ptr_conv;
15794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15795         this_ptr_conv.is_owned = false;
15796         LDKPublicKey val_ref;
15797         CHECK(*((uint32_t*)val) == 33);
15798         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15799         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15800 }
15801
15802 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) {
15803         LDKThirtyTwoBytes channel_id_arg_ref;
15804         CHECK(*((uint32_t*)channel_id_arg) == 32);
15805         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15806         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15807         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
15808         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
15809         LDKPublicKey next_per_commitment_point_arg_ref;
15810         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15811         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15812         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15815         uint64_t ret_ref = (uint64_t)ret_var.inner;
15816         if (ret_var.is_owned) {
15817                 ret_ref |= 1;
15818         }
15819         return ret_ref;
15820 }
15821
15822 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
15823         LDKRevokeAndACK orig_conv;
15824         orig_conv.inner = (void*)(orig & (~1));
15825         orig_conv.is_owned = false;
15826         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15829         uint64_t ret_ref = (uint64_t)ret_var.inner;
15830         if (ret_var.is_owned) {
15831                 ret_ref |= 1;
15832         }
15833         return ret_ref;
15834 }
15835
15836 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
15837         LDKUpdateFee this_obj_conv;
15838         this_obj_conv.inner = (void*)(this_obj & (~1));
15839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15840         UpdateFee_free(this_obj_conv);
15841 }
15842
15843 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
15844         LDKUpdateFee this_ptr_conv;
15845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15846         this_ptr_conv.is_owned = false;
15847         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15848         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
15849         return ret_arr;
15850 }
15851
15852 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15853         LDKUpdateFee this_ptr_conv;
15854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15855         this_ptr_conv.is_owned = false;
15856         LDKThirtyTwoBytes val_ref;
15857         CHECK(*((uint32_t*)val) == 32);
15858         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15859         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15860 }
15861
15862 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
15863         LDKUpdateFee this_ptr_conv;
15864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15865         this_ptr_conv.is_owned = false;
15866         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15867         return ret_val;
15868 }
15869
15870 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
15871         LDKUpdateFee this_ptr_conv;
15872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15873         this_ptr_conv.is_owned = false;
15874         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15875 }
15876
15877 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
15878         LDKThirtyTwoBytes channel_id_arg_ref;
15879         CHECK(*((uint32_t*)channel_id_arg) == 32);
15880         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15881         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15882         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15883         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15884         uint64_t ret_ref = (uint64_t)ret_var.inner;
15885         if (ret_var.is_owned) {
15886                 ret_ref |= 1;
15887         }
15888         return ret_ref;
15889 }
15890
15891 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
15892         LDKUpdateFee orig_conv;
15893         orig_conv.inner = (void*)(orig & (~1));
15894         orig_conv.is_owned = false;
15895         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15898         uint64_t ret_ref = (uint64_t)ret_var.inner;
15899         if (ret_var.is_owned) {
15900                 ret_ref |= 1;
15901         }
15902         return ret_ref;
15903 }
15904
15905 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
15906         LDKDataLossProtect this_obj_conv;
15907         this_obj_conv.inner = (void*)(this_obj & (~1));
15908         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15909         DataLossProtect_free(this_obj_conv);
15910 }
15911
15912 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
15913         LDKDataLossProtect this_ptr_conv;
15914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15915         this_ptr_conv.is_owned = false;
15916         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15917         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
15918         return ret_arr;
15919 }
15920
15921 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15922         LDKDataLossProtect this_ptr_conv;
15923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15924         this_ptr_conv.is_owned = false;
15925         LDKThirtyTwoBytes val_ref;
15926         CHECK(*((uint32_t*)val) == 32);
15927         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15928         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15929 }
15930
15931 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
15932         LDKDataLossProtect this_ptr_conv;
15933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15934         this_ptr_conv.is_owned = false;
15935         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15936         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15937         return ret_arr;
15938 }
15939
15940 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15941         LDKDataLossProtect this_ptr_conv;
15942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15943         this_ptr_conv.is_owned = false;
15944         LDKPublicKey val_ref;
15945         CHECK(*((uint32_t*)val) == 33);
15946         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15947         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15948 }
15949
15950 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
15951         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15952         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
15953         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
15954         LDKPublicKey my_current_per_commitment_point_arg_ref;
15955         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
15956         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
15957         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15958         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15959         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15960         uint64_t ret_ref = (uint64_t)ret_var.inner;
15961         if (ret_var.is_owned) {
15962                 ret_ref |= 1;
15963         }
15964         return ret_ref;
15965 }
15966
15967 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
15968         LDKDataLossProtect orig_conv;
15969         orig_conv.inner = (void*)(orig & (~1));
15970         orig_conv.is_owned = false;
15971         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15974         uint64_t ret_ref = (uint64_t)ret_var.inner;
15975         if (ret_var.is_owned) {
15976                 ret_ref |= 1;
15977         }
15978         return ret_ref;
15979 }
15980
15981 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
15982         LDKChannelReestablish this_obj_conv;
15983         this_obj_conv.inner = (void*)(this_obj & (~1));
15984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15985         ChannelReestablish_free(this_obj_conv);
15986 }
15987
15988 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
15989         LDKChannelReestablish this_ptr_conv;
15990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15991         this_ptr_conv.is_owned = false;
15992         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15993         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
15994         return ret_arr;
15995 }
15996
15997 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15998         LDKChannelReestablish this_ptr_conv;
15999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16000         this_ptr_conv.is_owned = false;
16001         LDKThirtyTwoBytes val_ref;
16002         CHECK(*((uint32_t*)val) == 32);
16003         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16004         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
16005 }
16006
16007 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
16008         LDKChannelReestablish this_ptr_conv;
16009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16010         this_ptr_conv.is_owned = false;
16011         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
16012         return ret_val;
16013 }
16014
16015 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
16016         LDKChannelReestablish this_ptr_conv;
16017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16018         this_ptr_conv.is_owned = false;
16019         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
16020 }
16021
16022 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
16023         LDKChannelReestablish this_ptr_conv;
16024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16025         this_ptr_conv.is_owned = false;
16026         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
16027         return ret_val;
16028 }
16029
16030 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
16031         LDKChannelReestablish this_ptr_conv;
16032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16033         this_ptr_conv.is_owned = false;
16034         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
16035 }
16036
16037 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
16038         LDKChannelReestablish orig_conv;
16039         orig_conv.inner = (void*)(orig & (~1));
16040         orig_conv.is_owned = false;
16041         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
16042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16044         uint64_t ret_ref = (uint64_t)ret_var.inner;
16045         if (ret_var.is_owned) {
16046                 ret_ref |= 1;
16047         }
16048         return ret_ref;
16049 }
16050
16051 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
16052         LDKAnnouncementSignatures this_obj_conv;
16053         this_obj_conv.inner = (void*)(this_obj & (~1));
16054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16055         AnnouncementSignatures_free(this_obj_conv);
16056 }
16057
16058 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
16059         LDKAnnouncementSignatures this_ptr_conv;
16060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16061         this_ptr_conv.is_owned = false;
16062         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16063         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
16064         return ret_arr;
16065 }
16066
16067 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16068         LDKAnnouncementSignatures this_ptr_conv;
16069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16070         this_ptr_conv.is_owned = false;
16071         LDKThirtyTwoBytes val_ref;
16072         CHECK(*((uint32_t*)val) == 32);
16073         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16074         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
16075 }
16076
16077 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
16078         LDKAnnouncementSignatures this_ptr_conv;
16079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16080         this_ptr_conv.is_owned = false;
16081         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
16082         return ret_val;
16083 }
16084
16085 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16086         LDKAnnouncementSignatures this_ptr_conv;
16087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16088         this_ptr_conv.is_owned = false;
16089         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
16090 }
16091
16092 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
16093         LDKAnnouncementSignatures this_ptr_conv;
16094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16095         this_ptr_conv.is_owned = false;
16096         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16097         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
16098         return ret_arr;
16099 }
16100
16101 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
16102         LDKAnnouncementSignatures this_ptr_conv;
16103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16104         this_ptr_conv.is_owned = false;
16105         LDKSignature val_ref;
16106         CHECK(*((uint32_t*)val) == 64);
16107         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16108         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
16109 }
16110
16111 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
16112         LDKAnnouncementSignatures this_ptr_conv;
16113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16114         this_ptr_conv.is_owned = false;
16115         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16116         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
16117         return ret_arr;
16118 }
16119
16120 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
16121         LDKAnnouncementSignatures this_ptr_conv;
16122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16123         this_ptr_conv.is_owned = false;
16124         LDKSignature val_ref;
16125         CHECK(*((uint32_t*)val) == 64);
16126         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16127         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
16128 }
16129
16130 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) {
16131         LDKThirtyTwoBytes channel_id_arg_ref;
16132         CHECK(*((uint32_t*)channel_id_arg) == 32);
16133         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16134         LDKSignature node_signature_arg_ref;
16135         CHECK(*((uint32_t*)node_signature_arg) == 64);
16136         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
16137         LDKSignature bitcoin_signature_arg_ref;
16138         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
16139         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
16140         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
16141         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16142         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16143         uint64_t ret_ref = (uint64_t)ret_var.inner;
16144         if (ret_var.is_owned) {
16145                 ret_ref |= 1;
16146         }
16147         return ret_ref;
16148 }
16149
16150 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
16151         LDKAnnouncementSignatures orig_conv;
16152         orig_conv.inner = (void*)(orig & (~1));
16153         orig_conv.is_owned = false;
16154         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
16155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16157         uint64_t ret_ref = (uint64_t)ret_var.inner;
16158         if (ret_var.is_owned) {
16159                 ret_ref |= 1;
16160         }
16161         return ret_ref;
16162 }
16163
16164 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
16165         if ((this_ptr & 1) != 0) return;
16166         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
16167         FREE((void*)this_ptr);
16168         NetAddress_free(this_ptr_conv);
16169 }
16170
16171 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
16172         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
16173         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
16174         *ret_copy = NetAddress_clone(orig_conv);
16175         uint64_t ret_ref = (uint64_t)ret_copy;
16176         return ret_ref;
16177 }
16178
16179 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
16180         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
16181         LDKCVec_u8Z ret_var = NetAddress_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_Result_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_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
16193         *ret_conv = Result_read(ser_ref);
16194         return (uint64_t)ret_conv;
16195 }
16196
16197 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
16198         LDKu8slice ser_ref;
16199         ser_ref.datalen = *((uint32_t*)ser);
16200         ser_ref.data = (int8_t*)(ser + 4);
16201         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
16202         *ret_conv = NetAddress_read(ser_ref);
16203         return (uint64_t)ret_conv;
16204 }
16205
16206 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
16207         LDKUnsignedNodeAnnouncement this_obj_conv;
16208         this_obj_conv.inner = (void*)(this_obj & (~1));
16209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16210         UnsignedNodeAnnouncement_free(this_obj_conv);
16211 }
16212
16213 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
16214         LDKUnsignedNodeAnnouncement this_ptr_conv;
16215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16216         this_ptr_conv.is_owned = false;
16217         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
16218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16220         uint64_t ret_ref = (uint64_t)ret_var.inner;
16221         if (ret_var.is_owned) {
16222                 ret_ref |= 1;
16223         }
16224         return ret_ref;
16225 }
16226
16227 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16228         LDKUnsignedNodeAnnouncement this_ptr_conv;
16229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16230         this_ptr_conv.is_owned = false;
16231         LDKNodeFeatures val_conv;
16232         val_conv.inner = (void*)(val & (~1));
16233         val_conv.is_owned = (val & 1) || (val == 0);
16234         val_conv = NodeFeatures_clone(&val_conv);
16235         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
16236 }
16237
16238 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
16239         LDKUnsignedNodeAnnouncement this_ptr_conv;
16240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16241         this_ptr_conv.is_owned = false;
16242         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
16243         return ret_val;
16244 }
16245
16246 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
16247         LDKUnsignedNodeAnnouncement this_ptr_conv;
16248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16249         this_ptr_conv.is_owned = false;
16250         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
16251 }
16252
16253 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
16254         LDKUnsignedNodeAnnouncement this_ptr_conv;
16255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16256         this_ptr_conv.is_owned = false;
16257         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16258         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
16259         return ret_arr;
16260 }
16261
16262 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
16263         LDKUnsignedNodeAnnouncement this_ptr_conv;
16264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16265         this_ptr_conv.is_owned = false;
16266         LDKPublicKey val_ref;
16267         CHECK(*((uint32_t*)val) == 33);
16268         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16269         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
16270 }
16271
16272 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
16273         LDKUnsignedNodeAnnouncement this_ptr_conv;
16274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16275         this_ptr_conv.is_owned = false;
16276         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
16277         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
16278         return ret_arr;
16279 }
16280
16281 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
16282         LDKUnsignedNodeAnnouncement this_ptr_conv;
16283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16284         this_ptr_conv.is_owned = false;
16285         LDKThreeBytes val_ref;
16286         CHECK(*((uint32_t*)val) == 3);
16287         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
16288         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
16289 }
16290
16291 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
16292         LDKUnsignedNodeAnnouncement this_ptr_conv;
16293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16294         this_ptr_conv.is_owned = false;
16295         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16296         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
16297         return ret_arr;
16298 }
16299
16300 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
16301         LDKUnsignedNodeAnnouncement this_ptr_conv;
16302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16303         this_ptr_conv.is_owned = false;
16304         LDKThirtyTwoBytes val_ref;
16305         CHECK(*((uint32_t*)val) == 32);
16306         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16307         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
16308 }
16309
16310 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
16311         LDKUnsignedNodeAnnouncement this_ptr_conv;
16312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16313         this_ptr_conv.is_owned = false;
16314         LDKCVec_NetAddressZ val_constr;
16315         val_constr.datalen = *((uint32_t*)val);
16316         if (val_constr.datalen > 0)
16317                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16318         else
16319                 val_constr.data = NULL;
16320         uint32_t* val_vals = (uint32_t*)(val + 4);
16321         for (size_t m = 0; m < val_constr.datalen; m++) {
16322                 uint32_t val_conv_12 = val_vals[m];
16323                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
16324                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
16325                 val_constr.data[m] = val_conv_12_conv;
16326         }
16327         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
16328 }
16329
16330 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
16331         LDKUnsignedNodeAnnouncement orig_conv;
16332         orig_conv.inner = (void*)(orig & (~1));
16333         orig_conv.is_owned = false;
16334         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
16335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16337         uint64_t ret_ref = (uint64_t)ret_var.inner;
16338         if (ret_var.is_owned) {
16339                 ret_ref |= 1;
16340         }
16341         return ret_ref;
16342 }
16343
16344 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
16345         LDKNodeAnnouncement this_obj_conv;
16346         this_obj_conv.inner = (void*)(this_obj & (~1));
16347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16348         NodeAnnouncement_free(this_obj_conv);
16349 }
16350
16351 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
16352         LDKNodeAnnouncement this_ptr_conv;
16353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16354         this_ptr_conv.is_owned = false;
16355         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16356         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
16357         return ret_arr;
16358 }
16359
16360 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
16361         LDKNodeAnnouncement this_ptr_conv;
16362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16363         this_ptr_conv.is_owned = false;
16364         LDKSignature val_ref;
16365         CHECK(*((uint32_t*)val) == 64);
16366         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16367         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
16368 }
16369
16370 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
16371         LDKNodeAnnouncement this_ptr_conv;
16372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16373         this_ptr_conv.is_owned = false;
16374         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
16375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16377         uint64_t ret_ref = (uint64_t)ret_var.inner;
16378         if (ret_var.is_owned) {
16379                 ret_ref |= 1;
16380         }
16381         return ret_ref;
16382 }
16383
16384 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16385         LDKNodeAnnouncement this_ptr_conv;
16386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16387         this_ptr_conv.is_owned = false;
16388         LDKUnsignedNodeAnnouncement val_conv;
16389         val_conv.inner = (void*)(val & (~1));
16390         val_conv.is_owned = (val & 1) || (val == 0);
16391         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
16392         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
16393 }
16394
16395 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
16396         LDKSignature signature_arg_ref;
16397         CHECK(*((uint32_t*)signature_arg) == 64);
16398         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16399         LDKUnsignedNodeAnnouncement contents_arg_conv;
16400         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16401         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16402         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
16403         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
16404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16406         uint64_t ret_ref = (uint64_t)ret_var.inner;
16407         if (ret_var.is_owned) {
16408                 ret_ref |= 1;
16409         }
16410         return ret_ref;
16411 }
16412
16413 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
16414         LDKNodeAnnouncement orig_conv;
16415         orig_conv.inner = (void*)(orig & (~1));
16416         orig_conv.is_owned = false;
16417         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
16418         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16419         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16420         uint64_t ret_ref = (uint64_t)ret_var.inner;
16421         if (ret_var.is_owned) {
16422                 ret_ref |= 1;
16423         }
16424         return ret_ref;
16425 }
16426
16427 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
16428         LDKUnsignedChannelAnnouncement this_obj_conv;
16429         this_obj_conv.inner = (void*)(this_obj & (~1));
16430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16431         UnsignedChannelAnnouncement_free(this_obj_conv);
16432 }
16433
16434 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
16435         LDKUnsignedChannelAnnouncement this_ptr_conv;
16436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16437         this_ptr_conv.is_owned = false;
16438         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
16439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16441         uint64_t ret_ref = (uint64_t)ret_var.inner;
16442         if (ret_var.is_owned) {
16443                 ret_ref |= 1;
16444         }
16445         return ret_ref;
16446 }
16447
16448 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16449         LDKUnsignedChannelAnnouncement this_ptr_conv;
16450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16451         this_ptr_conv.is_owned = false;
16452         LDKChannelFeatures val_conv;
16453         val_conv.inner = (void*)(val & (~1));
16454         val_conv.is_owned = (val & 1) || (val == 0);
16455         val_conv = ChannelFeatures_clone(&val_conv);
16456         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
16457 }
16458
16459 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
16460         LDKUnsignedChannelAnnouncement this_ptr_conv;
16461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16462         this_ptr_conv.is_owned = false;
16463         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16464         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
16465         return ret_arr;
16466 }
16467
16468 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16469         LDKUnsignedChannelAnnouncement this_ptr_conv;
16470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16471         this_ptr_conv.is_owned = false;
16472         LDKThirtyTwoBytes val_ref;
16473         CHECK(*((uint32_t*)val) == 32);
16474         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16475         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16476 }
16477
16478 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
16479         LDKUnsignedChannelAnnouncement this_ptr_conv;
16480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16481         this_ptr_conv.is_owned = false;
16482         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16483         return ret_val;
16484 }
16485
16486 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16487         LDKUnsignedChannelAnnouncement this_ptr_conv;
16488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16489         this_ptr_conv.is_owned = false;
16490         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16491 }
16492
16493 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
16494         LDKUnsignedChannelAnnouncement this_ptr_conv;
16495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16496         this_ptr_conv.is_owned = false;
16497         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16498         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
16499         return ret_arr;
16500 }
16501
16502 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
16503         LDKUnsignedChannelAnnouncement this_ptr_conv;
16504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16505         this_ptr_conv.is_owned = false;
16506         LDKPublicKey val_ref;
16507         CHECK(*((uint32_t*)val) == 33);
16508         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16509         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16510 }
16511
16512 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
16513         LDKUnsignedChannelAnnouncement this_ptr_conv;
16514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16515         this_ptr_conv.is_owned = false;
16516         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16517         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
16518         return ret_arr;
16519 }
16520
16521 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
16522         LDKUnsignedChannelAnnouncement this_ptr_conv;
16523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16524         this_ptr_conv.is_owned = false;
16525         LDKPublicKey val_ref;
16526         CHECK(*((uint32_t*)val) == 33);
16527         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16528         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16529 }
16530
16531 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
16532         LDKUnsignedChannelAnnouncement this_ptr_conv;
16533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16534         this_ptr_conv.is_owned = false;
16535         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16536         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
16537         return ret_arr;
16538 }
16539
16540 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
16541         LDKUnsignedChannelAnnouncement this_ptr_conv;
16542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16543         this_ptr_conv.is_owned = false;
16544         LDKPublicKey val_ref;
16545         CHECK(*((uint32_t*)val) == 33);
16546         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16547         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16548 }
16549
16550 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
16551         LDKUnsignedChannelAnnouncement this_ptr_conv;
16552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16553         this_ptr_conv.is_owned = false;
16554         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16555         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
16556         return ret_arr;
16557 }
16558
16559 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
16560         LDKUnsignedChannelAnnouncement this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         LDKPublicKey val_ref;
16564         CHECK(*((uint32_t*)val) == 33);
16565         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16566         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16567 }
16568
16569 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
16570         LDKUnsignedChannelAnnouncement orig_conv;
16571         orig_conv.inner = (void*)(orig & (~1));
16572         orig_conv.is_owned = false;
16573         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16576         uint64_t ret_ref = (uint64_t)ret_var.inner;
16577         if (ret_var.is_owned) {
16578                 ret_ref |= 1;
16579         }
16580         return ret_ref;
16581 }
16582
16583 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
16584         LDKChannelAnnouncement this_obj_conv;
16585         this_obj_conv.inner = (void*)(this_obj & (~1));
16586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16587         ChannelAnnouncement_free(this_obj_conv);
16588 }
16589
16590 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
16591         LDKChannelAnnouncement this_ptr_conv;
16592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16593         this_ptr_conv.is_owned = false;
16594         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16595         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
16596         return ret_arr;
16597 }
16598
16599 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
16600         LDKChannelAnnouncement this_ptr_conv;
16601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16602         this_ptr_conv.is_owned = false;
16603         LDKSignature val_ref;
16604         CHECK(*((uint32_t*)val) == 64);
16605         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16606         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16607 }
16608
16609 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
16610         LDKChannelAnnouncement this_ptr_conv;
16611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16612         this_ptr_conv.is_owned = false;
16613         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16614         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
16615         return ret_arr;
16616 }
16617
16618 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
16619         LDKChannelAnnouncement this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         LDKSignature val_ref;
16623         CHECK(*((uint32_t*)val) == 64);
16624         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16625         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16626 }
16627
16628 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
16629         LDKChannelAnnouncement this_ptr_conv;
16630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16631         this_ptr_conv.is_owned = false;
16632         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16633         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
16634         return ret_arr;
16635 }
16636
16637 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
16638         LDKChannelAnnouncement this_ptr_conv;
16639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16640         this_ptr_conv.is_owned = false;
16641         LDKSignature val_ref;
16642         CHECK(*((uint32_t*)val) == 64);
16643         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16644         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16645 }
16646
16647 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
16648         LDKChannelAnnouncement this_ptr_conv;
16649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16650         this_ptr_conv.is_owned = false;
16651         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16652         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
16653         return ret_arr;
16654 }
16655
16656 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
16657         LDKChannelAnnouncement this_ptr_conv;
16658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16659         this_ptr_conv.is_owned = false;
16660         LDKSignature val_ref;
16661         CHECK(*((uint32_t*)val) == 64);
16662         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16663         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16664 }
16665
16666 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
16667         LDKChannelAnnouncement this_ptr_conv;
16668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16669         this_ptr_conv.is_owned = false;
16670         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16673         uint64_t ret_ref = (uint64_t)ret_var.inner;
16674         if (ret_var.is_owned) {
16675                 ret_ref |= 1;
16676         }
16677         return ret_ref;
16678 }
16679
16680 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16681         LDKChannelAnnouncement this_ptr_conv;
16682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16683         this_ptr_conv.is_owned = false;
16684         LDKUnsignedChannelAnnouncement val_conv;
16685         val_conv.inner = (void*)(val & (~1));
16686         val_conv.is_owned = (val & 1) || (val == 0);
16687         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16688         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16689 }
16690
16691 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) {
16692         LDKSignature node_signature_1_arg_ref;
16693         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
16694         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
16695         LDKSignature node_signature_2_arg_ref;
16696         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
16697         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
16698         LDKSignature bitcoin_signature_1_arg_ref;
16699         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
16700         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
16701         LDKSignature bitcoin_signature_2_arg_ref;
16702         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
16703         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
16704         LDKUnsignedChannelAnnouncement contents_arg_conv;
16705         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16706         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16707         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16708         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);
16709         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16710         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16711         uint64_t ret_ref = (uint64_t)ret_var.inner;
16712         if (ret_var.is_owned) {
16713                 ret_ref |= 1;
16714         }
16715         return ret_ref;
16716 }
16717
16718 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
16719         LDKChannelAnnouncement orig_conv;
16720         orig_conv.inner = (void*)(orig & (~1));
16721         orig_conv.is_owned = false;
16722         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16725         uint64_t ret_ref = (uint64_t)ret_var.inner;
16726         if (ret_var.is_owned) {
16727                 ret_ref |= 1;
16728         }
16729         return ret_ref;
16730 }
16731
16732 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
16733         LDKUnsignedChannelUpdate this_obj_conv;
16734         this_obj_conv.inner = (void*)(this_obj & (~1));
16735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16736         UnsignedChannelUpdate_free(this_obj_conv);
16737 }
16738
16739 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
16740         LDKUnsignedChannelUpdate this_ptr_conv;
16741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16742         this_ptr_conv.is_owned = false;
16743         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16744         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
16745         return ret_arr;
16746 }
16747
16748 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16749         LDKUnsignedChannelUpdate this_ptr_conv;
16750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16751         this_ptr_conv.is_owned = false;
16752         LDKThirtyTwoBytes val_ref;
16753         CHECK(*((uint32_t*)val) == 32);
16754         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16755         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16756 }
16757
16758 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
16759         LDKUnsignedChannelUpdate this_ptr_conv;
16760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16761         this_ptr_conv.is_owned = false;
16762         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16763         return ret_val;
16764 }
16765
16766 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16767         LDKUnsignedChannelUpdate this_ptr_conv;
16768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16769         this_ptr_conv.is_owned = false;
16770         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16771 }
16772
16773 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
16774         LDKUnsignedChannelUpdate this_ptr_conv;
16775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16776         this_ptr_conv.is_owned = false;
16777         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16778         return ret_val;
16779 }
16780
16781 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
16782         LDKUnsignedChannelUpdate this_ptr_conv;
16783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16784         this_ptr_conv.is_owned = false;
16785         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16786 }
16787
16788 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
16789         LDKUnsignedChannelUpdate this_ptr_conv;
16790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16791         this_ptr_conv.is_owned = false;
16792         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16793         return ret_val;
16794 }
16795
16796 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
16797         LDKUnsignedChannelUpdate this_ptr_conv;
16798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16799         this_ptr_conv.is_owned = false;
16800         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16801 }
16802
16803 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
16804         LDKUnsignedChannelUpdate this_ptr_conv;
16805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16806         this_ptr_conv.is_owned = false;
16807         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16808         return ret_val;
16809 }
16810
16811 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
16812         LDKUnsignedChannelUpdate this_ptr_conv;
16813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16814         this_ptr_conv.is_owned = false;
16815         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16816 }
16817
16818 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
16819         LDKUnsignedChannelUpdate this_ptr_conv;
16820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16821         this_ptr_conv.is_owned = false;
16822         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16823         return ret_val;
16824 }
16825
16826 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16827         LDKUnsignedChannelUpdate this_ptr_conv;
16828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16829         this_ptr_conv.is_owned = false;
16830         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16831 }
16832
16833 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
16834         LDKUnsignedChannelUpdate this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16838         return ret_val;
16839 }
16840
16841 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
16842         LDKUnsignedChannelUpdate this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16846 }
16847
16848 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
16849         LDKUnsignedChannelUpdate this_ptr_conv;
16850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16851         this_ptr_conv.is_owned = false;
16852         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16853         return ret_val;
16854 }
16855
16856 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
16857         LDKUnsignedChannelUpdate this_ptr_conv;
16858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16859         this_ptr_conv.is_owned = false;
16860         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16861 }
16862
16863 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
16864         LDKUnsignedChannelUpdate orig_conv;
16865         orig_conv.inner = (void*)(orig & (~1));
16866         orig_conv.is_owned = false;
16867         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16868         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16869         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16870         uint64_t ret_ref = (uint64_t)ret_var.inner;
16871         if (ret_var.is_owned) {
16872                 ret_ref |= 1;
16873         }
16874         return ret_ref;
16875 }
16876
16877 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
16878         LDKChannelUpdate this_obj_conv;
16879         this_obj_conv.inner = (void*)(this_obj & (~1));
16880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16881         ChannelUpdate_free(this_obj_conv);
16882 }
16883
16884 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
16885         LDKChannelUpdate this_ptr_conv;
16886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16887         this_ptr_conv.is_owned = false;
16888         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16889         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
16890         return ret_arr;
16891 }
16892
16893 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
16894         LDKChannelUpdate this_ptr_conv;
16895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16896         this_ptr_conv.is_owned = false;
16897         LDKSignature val_ref;
16898         CHECK(*((uint32_t*)val) == 64);
16899         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16900         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16901 }
16902
16903 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
16904         LDKChannelUpdate this_ptr_conv;
16905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16906         this_ptr_conv.is_owned = false;
16907         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16910         uint64_t ret_ref = (uint64_t)ret_var.inner;
16911         if (ret_var.is_owned) {
16912                 ret_ref |= 1;
16913         }
16914         return ret_ref;
16915 }
16916
16917 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
16918         LDKChannelUpdate this_ptr_conv;
16919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16920         this_ptr_conv.is_owned = false;
16921         LDKUnsignedChannelUpdate val_conv;
16922         val_conv.inner = (void*)(val & (~1));
16923         val_conv.is_owned = (val & 1) || (val == 0);
16924         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16925         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16926 }
16927
16928 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
16929         LDKSignature signature_arg_ref;
16930         CHECK(*((uint32_t*)signature_arg) == 64);
16931         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16932         LDKUnsignedChannelUpdate contents_arg_conv;
16933         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16934         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16935         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16936         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16939         uint64_t ret_ref = (uint64_t)ret_var.inner;
16940         if (ret_var.is_owned) {
16941                 ret_ref |= 1;
16942         }
16943         return ret_ref;
16944 }
16945
16946 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
16947         LDKChannelUpdate orig_conv;
16948         orig_conv.inner = (void*)(orig & (~1));
16949         orig_conv.is_owned = false;
16950         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16953         uint64_t ret_ref = (uint64_t)ret_var.inner;
16954         if (ret_var.is_owned) {
16955                 ret_ref |= 1;
16956         }
16957         return ret_ref;
16958 }
16959
16960 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
16961         LDKQueryChannelRange this_obj_conv;
16962         this_obj_conv.inner = (void*)(this_obj & (~1));
16963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16964         QueryChannelRange_free(this_obj_conv);
16965 }
16966
16967 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
16968         LDKQueryChannelRange this_ptr_conv;
16969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16970         this_ptr_conv.is_owned = false;
16971         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16972         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
16973         return ret_arr;
16974 }
16975
16976 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16977         LDKQueryChannelRange this_ptr_conv;
16978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16979         this_ptr_conv.is_owned = false;
16980         LDKThirtyTwoBytes val_ref;
16981         CHECK(*((uint32_t*)val) == 32);
16982         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16983         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16984 }
16985
16986 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
16987         LDKQueryChannelRange this_ptr_conv;
16988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16989         this_ptr_conv.is_owned = false;
16990         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16991         return ret_val;
16992 }
16993
16994 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16995         LDKQueryChannelRange this_ptr_conv;
16996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16997         this_ptr_conv.is_owned = false;
16998         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
16999 }
17000
17001 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
17002         LDKQueryChannelRange this_ptr_conv;
17003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17004         this_ptr_conv.is_owned = false;
17005         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
17006         return ret_val;
17007 }
17008
17009 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
17010         LDKQueryChannelRange this_ptr_conv;
17011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17012         this_ptr_conv.is_owned = false;
17013         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
17014 }
17015
17016 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
17017         LDKThirtyTwoBytes chain_hash_arg_ref;
17018         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17019         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17020         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
17021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17023         uint64_t ret_ref = (uint64_t)ret_var.inner;
17024         if (ret_var.is_owned) {
17025                 ret_ref |= 1;
17026         }
17027         return ret_ref;
17028 }
17029
17030 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
17031         LDKQueryChannelRange orig_conv;
17032         orig_conv.inner = (void*)(orig & (~1));
17033         orig_conv.is_owned = false;
17034         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
17035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17037         uint64_t ret_ref = (uint64_t)ret_var.inner;
17038         if (ret_var.is_owned) {
17039                 ret_ref |= 1;
17040         }
17041         return ret_ref;
17042 }
17043
17044 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
17045         LDKReplyChannelRange this_obj_conv;
17046         this_obj_conv.inner = (void*)(this_obj & (~1));
17047         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17048         ReplyChannelRange_free(this_obj_conv);
17049 }
17050
17051 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
17052         LDKReplyChannelRange this_ptr_conv;
17053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17054         this_ptr_conv.is_owned = false;
17055         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17056         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
17057         return ret_arr;
17058 }
17059
17060 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17061         LDKReplyChannelRange this_ptr_conv;
17062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17063         this_ptr_conv.is_owned = false;
17064         LDKThirtyTwoBytes val_ref;
17065         CHECK(*((uint32_t*)val) == 32);
17066         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17067         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
17068 }
17069
17070 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
17071         LDKReplyChannelRange this_ptr_conv;
17072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17073         this_ptr_conv.is_owned = false;
17074         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
17075         return ret_val;
17076 }
17077
17078 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
17079         LDKReplyChannelRange this_ptr_conv;
17080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17081         this_ptr_conv.is_owned = false;
17082         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
17083 }
17084
17085 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
17086         LDKReplyChannelRange this_ptr_conv;
17087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17088         this_ptr_conv.is_owned = false;
17089         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
17090         return ret_val;
17091 }
17092
17093 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
17094         LDKReplyChannelRange this_ptr_conv;
17095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17096         this_ptr_conv.is_owned = false;
17097         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
17098 }
17099
17100 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
17101         LDKReplyChannelRange this_ptr_conv;
17102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17103         this_ptr_conv.is_owned = false;
17104         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
17105         return ret_val;
17106 }
17107
17108 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
17109         LDKReplyChannelRange this_ptr_conv;
17110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17111         this_ptr_conv.is_owned = false;
17112         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
17113 }
17114
17115 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
17116         LDKReplyChannelRange this_ptr_conv;
17117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17118         this_ptr_conv.is_owned = false;
17119         LDKCVec_u64Z val_constr;
17120         val_constr.datalen = *((uint32_t*)val);
17121         if (val_constr.datalen > 0)
17122                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17123         else
17124                 val_constr.data = NULL;
17125         int64_t* val_vals = (int64_t*)(val + 4);
17126         for (size_t i = 0; i < val_constr.datalen; i++) {
17127                 int64_t val_conv_8 = val_vals[i];
17128                 val_constr.data[i] = val_conv_8;
17129         }
17130         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
17131 }
17132
17133 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) {
17134         LDKThirtyTwoBytes chain_hash_arg_ref;
17135         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17136         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17137         LDKCVec_u64Z short_channel_ids_arg_constr;
17138         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
17139         if (short_channel_ids_arg_constr.datalen > 0)
17140                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17141         else
17142                 short_channel_ids_arg_constr.data = NULL;
17143         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
17144         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
17145                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
17146                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
17147         }
17148         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
17149         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17150         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17151         uint64_t ret_ref = (uint64_t)ret_var.inner;
17152         if (ret_var.is_owned) {
17153                 ret_ref |= 1;
17154         }
17155         return ret_ref;
17156 }
17157
17158 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
17159         LDKReplyChannelRange orig_conv;
17160         orig_conv.inner = (void*)(orig & (~1));
17161         orig_conv.is_owned = false;
17162         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
17163         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17164         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17165         uint64_t ret_ref = (uint64_t)ret_var.inner;
17166         if (ret_var.is_owned) {
17167                 ret_ref |= 1;
17168         }
17169         return ret_ref;
17170 }
17171
17172 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
17173         LDKQueryShortChannelIds this_obj_conv;
17174         this_obj_conv.inner = (void*)(this_obj & (~1));
17175         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17176         QueryShortChannelIds_free(this_obj_conv);
17177 }
17178
17179 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
17180         LDKQueryShortChannelIds this_ptr_conv;
17181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17182         this_ptr_conv.is_owned = false;
17183         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17184         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
17185         return ret_arr;
17186 }
17187
17188 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17189         LDKQueryShortChannelIds this_ptr_conv;
17190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17191         this_ptr_conv.is_owned = false;
17192         LDKThirtyTwoBytes val_ref;
17193         CHECK(*((uint32_t*)val) == 32);
17194         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17195         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
17196 }
17197
17198 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
17199         LDKQueryShortChannelIds this_ptr_conv;
17200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17201         this_ptr_conv.is_owned = false;
17202         LDKCVec_u64Z val_constr;
17203         val_constr.datalen = *((uint32_t*)val);
17204         if (val_constr.datalen > 0)
17205                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17206         else
17207                 val_constr.data = NULL;
17208         int64_t* val_vals = (int64_t*)(val + 4);
17209         for (size_t i = 0; i < val_constr.datalen; i++) {
17210                 int64_t val_conv_8 = val_vals[i];
17211                 val_constr.data[i] = val_conv_8;
17212         }
17213         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
17214 }
17215
17216 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
17217         LDKThirtyTwoBytes chain_hash_arg_ref;
17218         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17219         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17220         LDKCVec_u64Z short_channel_ids_arg_constr;
17221         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
17222         if (short_channel_ids_arg_constr.datalen > 0)
17223                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17224         else
17225                 short_channel_ids_arg_constr.data = NULL;
17226         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
17227         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
17228                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
17229                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
17230         }
17231         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
17232         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17233         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17234         uint64_t ret_ref = (uint64_t)ret_var.inner;
17235         if (ret_var.is_owned) {
17236                 ret_ref |= 1;
17237         }
17238         return ret_ref;
17239 }
17240
17241 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
17242         LDKQueryShortChannelIds orig_conv;
17243         orig_conv.inner = (void*)(orig & (~1));
17244         orig_conv.is_owned = false;
17245         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
17246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17248         uint64_t ret_ref = (uint64_t)ret_var.inner;
17249         if (ret_var.is_owned) {
17250                 ret_ref |= 1;
17251         }
17252         return ret_ref;
17253 }
17254
17255 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
17256         LDKReplyShortChannelIdsEnd this_obj_conv;
17257         this_obj_conv.inner = (void*)(this_obj & (~1));
17258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17259         ReplyShortChannelIdsEnd_free(this_obj_conv);
17260 }
17261
17262 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
17263         LDKReplyShortChannelIdsEnd this_ptr_conv;
17264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17265         this_ptr_conv.is_owned = false;
17266         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17267         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
17268         return ret_arr;
17269 }
17270
17271 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17272         LDKReplyShortChannelIdsEnd this_ptr_conv;
17273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17274         this_ptr_conv.is_owned = false;
17275         LDKThirtyTwoBytes val_ref;
17276         CHECK(*((uint32_t*)val) == 32);
17277         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17278         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
17279 }
17280
17281 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
17282         LDKReplyShortChannelIdsEnd this_ptr_conv;
17283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17284         this_ptr_conv.is_owned = false;
17285         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
17286         return ret_val;
17287 }
17288
17289 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
17290         LDKReplyShortChannelIdsEnd this_ptr_conv;
17291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17292         this_ptr_conv.is_owned = false;
17293         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
17294 }
17295
17296 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
17297         LDKThirtyTwoBytes chain_hash_arg_ref;
17298         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17299         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17300         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
17301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17303         uint64_t ret_ref = (uint64_t)ret_var.inner;
17304         if (ret_var.is_owned) {
17305                 ret_ref |= 1;
17306         }
17307         return ret_ref;
17308 }
17309
17310 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
17311         LDKReplyShortChannelIdsEnd orig_conv;
17312         orig_conv.inner = (void*)(orig & (~1));
17313         orig_conv.is_owned = false;
17314         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
17315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17317         uint64_t ret_ref = (uint64_t)ret_var.inner;
17318         if (ret_var.is_owned) {
17319                 ret_ref |= 1;
17320         }
17321         return ret_ref;
17322 }
17323
17324 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
17325         LDKGossipTimestampFilter this_obj_conv;
17326         this_obj_conv.inner = (void*)(this_obj & (~1));
17327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17328         GossipTimestampFilter_free(this_obj_conv);
17329 }
17330
17331 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
17332         LDKGossipTimestampFilter this_ptr_conv;
17333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17334         this_ptr_conv.is_owned = false;
17335         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17336         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
17337         return ret_arr;
17338 }
17339
17340 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17341         LDKGossipTimestampFilter this_ptr_conv;
17342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17343         this_ptr_conv.is_owned = false;
17344         LDKThirtyTwoBytes val_ref;
17345         CHECK(*((uint32_t*)val) == 32);
17346         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17347         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
17348 }
17349
17350 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
17351         LDKGossipTimestampFilter this_ptr_conv;
17352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17353         this_ptr_conv.is_owned = false;
17354         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
17355         return ret_val;
17356 }
17357
17358 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
17359         LDKGossipTimestampFilter this_ptr_conv;
17360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17361         this_ptr_conv.is_owned = false;
17362         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
17363 }
17364
17365 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
17366         LDKGossipTimestampFilter this_ptr_conv;
17367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17368         this_ptr_conv.is_owned = false;
17369         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
17370         return ret_val;
17371 }
17372
17373 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
17374         LDKGossipTimestampFilter this_ptr_conv;
17375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17376         this_ptr_conv.is_owned = false;
17377         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
17378 }
17379
17380 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
17381         LDKThirtyTwoBytes chain_hash_arg_ref;
17382         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17383         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17384         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
17385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17387         uint64_t ret_ref = (uint64_t)ret_var.inner;
17388         if (ret_var.is_owned) {
17389                 ret_ref |= 1;
17390         }
17391         return ret_ref;
17392 }
17393
17394 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
17395         LDKGossipTimestampFilter orig_conv;
17396         orig_conv.inner = (void*)(orig & (~1));
17397         orig_conv.is_owned = false;
17398         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
17399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17401         uint64_t ret_ref = (uint64_t)ret_var.inner;
17402         if (ret_var.is_owned) {
17403                 ret_ref |= 1;
17404         }
17405         return ret_ref;
17406 }
17407
17408 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
17409         if ((this_ptr & 1) != 0) return;
17410         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
17411         FREE((void*)this_ptr);
17412         ErrorAction_free(this_ptr_conv);
17413 }
17414
17415 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
17416         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
17417         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17418         *ret_copy = ErrorAction_clone(orig_conv);
17419         uint64_t ret_ref = (uint64_t)ret_copy;
17420         return ret_ref;
17421 }
17422
17423 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
17424         LDKLightningError this_obj_conv;
17425         this_obj_conv.inner = (void*)(this_obj & (~1));
17426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17427         LightningError_free(this_obj_conv);
17428 }
17429
17430 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
17431         LDKLightningError this_ptr_conv;
17432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17433         this_ptr_conv.is_owned = false;
17434         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
17435         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17436         return ret_conv;
17437 }
17438
17439 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
17440         LDKLightningError this_ptr_conv;
17441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17442         this_ptr_conv.is_owned = false;
17443         LDKStr val_conv = str_ref_to_owned_c(val);
17444         LightningError_set_err(&this_ptr_conv, val_conv);
17445 }
17446
17447 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
17448         LDKLightningError this_ptr_conv;
17449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17450         this_ptr_conv.is_owned = false;
17451         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17452         *ret_copy = LightningError_get_action(&this_ptr_conv);
17453         uint64_t ret_ref = (uint64_t)ret_copy;
17454         return ret_ref;
17455 }
17456
17457 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
17458         LDKLightningError this_ptr_conv;
17459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17460         this_ptr_conv.is_owned = false;
17461         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
17462         LightningError_set_action(&this_ptr_conv, val_conv);
17463 }
17464
17465 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
17466         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
17467         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17468         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
17469         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17470         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17471         uint64_t ret_ref = (uint64_t)ret_var.inner;
17472         if (ret_var.is_owned) {
17473                 ret_ref |= 1;
17474         }
17475         return ret_ref;
17476 }
17477
17478 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
17479         LDKLightningError orig_conv;
17480         orig_conv.inner = (void*)(orig & (~1));
17481         orig_conv.is_owned = false;
17482         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17485         uint64_t ret_ref = (uint64_t)ret_var.inner;
17486         if (ret_var.is_owned) {
17487                 ret_ref |= 1;
17488         }
17489         return ret_ref;
17490 }
17491
17492 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
17493         LDKCommitmentUpdate this_obj_conv;
17494         this_obj_conv.inner = (void*)(this_obj & (~1));
17495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17496         CommitmentUpdate_free(this_obj_conv);
17497 }
17498
17499 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
17500         LDKCommitmentUpdate this_ptr_conv;
17501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17502         this_ptr_conv.is_owned = false;
17503         LDKCVec_UpdateAddHTLCZ val_constr;
17504         val_constr.datalen = *((uint32_t*)val);
17505         if (val_constr.datalen > 0)
17506                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17507         else
17508                 val_constr.data = NULL;
17509         uint32_t* val_vals = (uint32_t*)(val + 4);
17510         for (size_t p = 0; p < val_constr.datalen; p++) {
17511                 uint32_t val_conv_15 = val_vals[p];
17512                 LDKUpdateAddHTLC val_conv_15_conv;
17513                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17514                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17515                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17516                 val_constr.data[p] = val_conv_15_conv;
17517         }
17518         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17519 }
17520
17521 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
17522         LDKCommitmentUpdate this_ptr_conv;
17523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17524         this_ptr_conv.is_owned = false;
17525         LDKCVec_UpdateFulfillHTLCZ val_constr;
17526         val_constr.datalen = *((uint32_t*)val);
17527         if (val_constr.datalen > 0)
17528                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17529         else
17530                 val_constr.data = NULL;
17531         uint32_t* val_vals = (uint32_t*)(val + 4);
17532         for (size_t t = 0; t < val_constr.datalen; t++) {
17533                 uint32_t val_conv_19 = val_vals[t];
17534                 LDKUpdateFulfillHTLC val_conv_19_conv;
17535                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17536                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17537                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17538                 val_constr.data[t] = val_conv_19_conv;
17539         }
17540         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17541 }
17542
17543 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
17544         LDKCommitmentUpdate this_ptr_conv;
17545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17546         this_ptr_conv.is_owned = false;
17547         LDKCVec_UpdateFailHTLCZ val_constr;
17548         val_constr.datalen = *((uint32_t*)val);
17549         if (val_constr.datalen > 0)
17550                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17551         else
17552                 val_constr.data = NULL;
17553         uint32_t* val_vals = (uint32_t*)(val + 4);
17554         for (size_t q = 0; q < val_constr.datalen; q++) {
17555                 uint32_t val_conv_16 = val_vals[q];
17556                 LDKUpdateFailHTLC val_conv_16_conv;
17557                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17558                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17559                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17560                 val_constr.data[q] = val_conv_16_conv;
17561         }
17562         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17563 }
17564
17565 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
17566         LDKCommitmentUpdate this_ptr_conv;
17567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17568         this_ptr_conv.is_owned = false;
17569         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17570         val_constr.datalen = *((uint32_t*)val);
17571         if (val_constr.datalen > 0)
17572                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17573         else
17574                 val_constr.data = NULL;
17575         uint32_t* val_vals = (uint32_t*)(val + 4);
17576         for (size_t z = 0; z < val_constr.datalen; z++) {
17577                 uint32_t val_conv_25 = val_vals[z];
17578                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17579                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17580                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17581                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17582                 val_constr.data[z] = val_conv_25_conv;
17583         }
17584         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17585 }
17586
17587 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
17588         LDKCommitmentUpdate this_ptr_conv;
17589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17590         this_ptr_conv.is_owned = false;
17591         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17594         uint64_t ret_ref = (uint64_t)ret_var.inner;
17595         if (ret_var.is_owned) {
17596                 ret_ref |= 1;
17597         }
17598         return ret_ref;
17599 }
17600
17601 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
17602         LDKCommitmentUpdate this_ptr_conv;
17603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17604         this_ptr_conv.is_owned = false;
17605         LDKUpdateFee val_conv;
17606         val_conv.inner = (void*)(val & (~1));
17607         val_conv.is_owned = (val & 1) || (val == 0);
17608         val_conv = UpdateFee_clone(&val_conv);
17609         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17610 }
17611
17612 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
17613         LDKCommitmentUpdate this_ptr_conv;
17614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17615         this_ptr_conv.is_owned = false;
17616         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17619         uint64_t ret_ref = (uint64_t)ret_var.inner;
17620         if (ret_var.is_owned) {
17621                 ret_ref |= 1;
17622         }
17623         return ret_ref;
17624 }
17625
17626 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
17627         LDKCommitmentUpdate this_ptr_conv;
17628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17629         this_ptr_conv.is_owned = false;
17630         LDKCommitmentSigned val_conv;
17631         val_conv.inner = (void*)(val & (~1));
17632         val_conv.is_owned = (val & 1) || (val == 0);
17633         val_conv = CommitmentSigned_clone(&val_conv);
17634         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17635 }
17636
17637 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) {
17638         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17639         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
17640         if (update_add_htlcs_arg_constr.datalen > 0)
17641                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17642         else
17643                 update_add_htlcs_arg_constr.data = NULL;
17644         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
17645         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17646                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17647                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17648                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17649                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17650                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17651                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17652         }
17653         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17654         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
17655         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17656                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17657         else
17658                 update_fulfill_htlcs_arg_constr.data = NULL;
17659         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
17660         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17661                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17662                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17663                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17664                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17665                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17666                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17667         }
17668         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17669         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
17670         if (update_fail_htlcs_arg_constr.datalen > 0)
17671                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17672         else
17673                 update_fail_htlcs_arg_constr.data = NULL;
17674         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
17675         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17676                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17677                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17678                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17679                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17680                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17681                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17682         }
17683         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17684         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
17685         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17686                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17687         else
17688                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17689         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
17690         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17691                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17692                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17693                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17694                 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);
17695                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17696                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17697         }
17698         LDKUpdateFee update_fee_arg_conv;
17699         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17700         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17701         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17702         LDKCommitmentSigned commitment_signed_arg_conv;
17703         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17704         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17705         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17706         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);
17707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17709         uint64_t ret_ref = (uint64_t)ret_var.inner;
17710         if (ret_var.is_owned) {
17711                 ret_ref |= 1;
17712         }
17713         return ret_ref;
17714 }
17715
17716 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
17717         LDKCommitmentUpdate orig_conv;
17718         orig_conv.inner = (void*)(orig & (~1));
17719         orig_conv.is_owned = false;
17720         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
17721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17723         uint64_t ret_ref = (uint64_t)ret_var.inner;
17724         if (ret_var.is_owned) {
17725                 ret_ref |= 1;
17726         }
17727         return ret_ref;
17728 }
17729
17730 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
17731         if ((this_ptr & 1) != 0) return;
17732         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17733         FREE((void*)this_ptr);
17734         HTLCFailChannelUpdate_free(this_ptr_conv);
17735 }
17736
17737 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
17738         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17739         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17740         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17741         uint64_t ret_ref = (uint64_t)ret_copy;
17742         return ret_ref;
17743 }
17744
17745 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
17746         if ((this_ptr & 1) != 0) return;
17747         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17748         FREE((void*)this_ptr);
17749         ChannelMessageHandler_free(this_ptr_conv);
17750 }
17751
17752 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
17753         if ((this_ptr & 1) != 0) return;
17754         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17755         FREE((void*)this_ptr);
17756         RoutingMessageHandler_free(this_ptr_conv);
17757 }
17758
17759 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
17760         LDKAcceptChannel obj_conv;
17761         obj_conv.inner = (void*)(obj & (~1));
17762         obj_conv.is_owned = false;
17763         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17764         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17765         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17766         CVec_u8Z_free(ret_var);
17767         return ret_arr;
17768 }
17769
17770 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
17771         LDKu8slice ser_ref;
17772         ser_ref.datalen = *((uint32_t*)ser);
17773         ser_ref.data = (int8_t*)(ser + 4);
17774         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17775         *ret_conv = AcceptChannel_read(ser_ref);
17776         return (uint64_t)ret_conv;
17777 }
17778
17779 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
17780         LDKAnnouncementSignatures obj_conv;
17781         obj_conv.inner = (void*)(obj & (~1));
17782         obj_conv.is_owned = false;
17783         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17784         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17785         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17786         CVec_u8Z_free(ret_var);
17787         return ret_arr;
17788 }
17789
17790 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
17791         LDKu8slice ser_ref;
17792         ser_ref.datalen = *((uint32_t*)ser);
17793         ser_ref.data = (int8_t*)(ser + 4);
17794         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17795         *ret_conv = AnnouncementSignatures_read(ser_ref);
17796         return (uint64_t)ret_conv;
17797 }
17798
17799 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
17800         LDKChannelReestablish obj_conv;
17801         obj_conv.inner = (void*)(obj & (~1));
17802         obj_conv.is_owned = false;
17803         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17804         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17805         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17806         CVec_u8Z_free(ret_var);
17807         return ret_arr;
17808 }
17809
17810 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
17811         LDKu8slice ser_ref;
17812         ser_ref.datalen = *((uint32_t*)ser);
17813         ser_ref.data = (int8_t*)(ser + 4);
17814         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17815         *ret_conv = ChannelReestablish_read(ser_ref);
17816         return (uint64_t)ret_conv;
17817 }
17818
17819 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
17820         LDKClosingSigned obj_conv;
17821         obj_conv.inner = (void*)(obj & (~1));
17822         obj_conv.is_owned = false;
17823         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17824         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17825         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17826         CVec_u8Z_free(ret_var);
17827         return ret_arr;
17828 }
17829
17830 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
17831         LDKu8slice ser_ref;
17832         ser_ref.datalen = *((uint32_t*)ser);
17833         ser_ref.data = (int8_t*)(ser + 4);
17834         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17835         *ret_conv = ClosingSigned_read(ser_ref);
17836         return (uint64_t)ret_conv;
17837 }
17838
17839 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
17840         LDKCommitmentSigned obj_conv;
17841         obj_conv.inner = (void*)(obj & (~1));
17842         obj_conv.is_owned = false;
17843         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17844         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17845         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17846         CVec_u8Z_free(ret_var);
17847         return ret_arr;
17848 }
17849
17850 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
17851         LDKu8slice ser_ref;
17852         ser_ref.datalen = *((uint32_t*)ser);
17853         ser_ref.data = (int8_t*)(ser + 4);
17854         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17855         *ret_conv = CommitmentSigned_read(ser_ref);
17856         return (uint64_t)ret_conv;
17857 }
17858
17859 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
17860         LDKFundingCreated obj_conv;
17861         obj_conv.inner = (void*)(obj & (~1));
17862         obj_conv.is_owned = false;
17863         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17864         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17865         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17866         CVec_u8Z_free(ret_var);
17867         return ret_arr;
17868 }
17869
17870 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
17871         LDKu8slice ser_ref;
17872         ser_ref.datalen = *((uint32_t*)ser);
17873         ser_ref.data = (int8_t*)(ser + 4);
17874         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17875         *ret_conv = FundingCreated_read(ser_ref);
17876         return (uint64_t)ret_conv;
17877 }
17878
17879 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
17880         LDKFundingSigned obj_conv;
17881         obj_conv.inner = (void*)(obj & (~1));
17882         obj_conv.is_owned = false;
17883         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17884         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17885         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17886         CVec_u8Z_free(ret_var);
17887         return ret_arr;
17888 }
17889
17890 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
17891         LDKu8slice ser_ref;
17892         ser_ref.datalen = *((uint32_t*)ser);
17893         ser_ref.data = (int8_t*)(ser + 4);
17894         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17895         *ret_conv = FundingSigned_read(ser_ref);
17896         return (uint64_t)ret_conv;
17897 }
17898
17899 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
17900         LDKFundingLocked obj_conv;
17901         obj_conv.inner = (void*)(obj & (~1));
17902         obj_conv.is_owned = false;
17903         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17904         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17905         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17906         CVec_u8Z_free(ret_var);
17907         return ret_arr;
17908 }
17909
17910 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
17911         LDKu8slice ser_ref;
17912         ser_ref.datalen = *((uint32_t*)ser);
17913         ser_ref.data = (int8_t*)(ser + 4);
17914         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17915         *ret_conv = FundingLocked_read(ser_ref);
17916         return (uint64_t)ret_conv;
17917 }
17918
17919 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
17920         LDKInit obj_conv;
17921         obj_conv.inner = (void*)(obj & (~1));
17922         obj_conv.is_owned = false;
17923         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17924         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17925         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17926         CVec_u8Z_free(ret_var);
17927         return ret_arr;
17928 }
17929
17930 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
17931         LDKu8slice ser_ref;
17932         ser_ref.datalen = *((uint32_t*)ser);
17933         ser_ref.data = (int8_t*)(ser + 4);
17934         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17935         *ret_conv = Init_read(ser_ref);
17936         return (uint64_t)ret_conv;
17937 }
17938
17939 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
17940         LDKOpenChannel obj_conv;
17941         obj_conv.inner = (void*)(obj & (~1));
17942         obj_conv.is_owned = false;
17943         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17944         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17945         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17946         CVec_u8Z_free(ret_var);
17947         return ret_arr;
17948 }
17949
17950 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
17951         LDKu8slice ser_ref;
17952         ser_ref.datalen = *((uint32_t*)ser);
17953         ser_ref.data = (int8_t*)(ser + 4);
17954         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17955         *ret_conv = OpenChannel_read(ser_ref);
17956         return (uint64_t)ret_conv;
17957 }
17958
17959 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
17960         LDKRevokeAndACK obj_conv;
17961         obj_conv.inner = (void*)(obj & (~1));
17962         obj_conv.is_owned = false;
17963         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17964         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17965         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17966         CVec_u8Z_free(ret_var);
17967         return ret_arr;
17968 }
17969
17970 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
17971         LDKu8slice ser_ref;
17972         ser_ref.datalen = *((uint32_t*)ser);
17973         ser_ref.data = (int8_t*)(ser + 4);
17974         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17975         *ret_conv = RevokeAndACK_read(ser_ref);
17976         return (uint64_t)ret_conv;
17977 }
17978
17979 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
17980         LDKShutdown obj_conv;
17981         obj_conv.inner = (void*)(obj & (~1));
17982         obj_conv.is_owned = false;
17983         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17984         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17985         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17986         CVec_u8Z_free(ret_var);
17987         return ret_arr;
17988 }
17989
17990 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
17991         LDKu8slice ser_ref;
17992         ser_ref.datalen = *((uint32_t*)ser);
17993         ser_ref.data = (int8_t*)(ser + 4);
17994         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17995         *ret_conv = Shutdown_read(ser_ref);
17996         return (uint64_t)ret_conv;
17997 }
17998
17999 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
18000         LDKUpdateFailHTLC obj_conv;
18001         obj_conv.inner = (void*)(obj & (~1));
18002         obj_conv.is_owned = false;
18003         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
18004         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18005         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18006         CVec_u8Z_free(ret_var);
18007         return ret_arr;
18008 }
18009
18010 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
18011         LDKu8slice ser_ref;
18012         ser_ref.datalen = *((uint32_t*)ser);
18013         ser_ref.data = (int8_t*)(ser + 4);
18014         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18015         *ret_conv = UpdateFailHTLC_read(ser_ref);
18016         return (uint64_t)ret_conv;
18017 }
18018
18019 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
18020         LDKUpdateFailMalformedHTLC obj_conv;
18021         obj_conv.inner = (void*)(obj & (~1));
18022         obj_conv.is_owned = false;
18023         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
18024         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18025         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18026         CVec_u8Z_free(ret_var);
18027         return ret_arr;
18028 }
18029
18030 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
18031         LDKu8slice ser_ref;
18032         ser_ref.datalen = *((uint32_t*)ser);
18033         ser_ref.data = (int8_t*)(ser + 4);
18034         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18035         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
18036         return (uint64_t)ret_conv;
18037 }
18038
18039 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
18040         LDKUpdateFee obj_conv;
18041         obj_conv.inner = (void*)(obj & (~1));
18042         obj_conv.is_owned = false;
18043         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
18044         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18045         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18046         CVec_u8Z_free(ret_var);
18047         return ret_arr;
18048 }
18049
18050 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
18051         LDKu8slice ser_ref;
18052         ser_ref.datalen = *((uint32_t*)ser);
18053         ser_ref.data = (int8_t*)(ser + 4);
18054         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18055         *ret_conv = UpdateFee_read(ser_ref);
18056         return (uint64_t)ret_conv;
18057 }
18058
18059 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
18060         LDKUpdateFulfillHTLC obj_conv;
18061         obj_conv.inner = (void*)(obj & (~1));
18062         obj_conv.is_owned = false;
18063         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
18064         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18065         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18066         CVec_u8Z_free(ret_var);
18067         return ret_arr;
18068 }
18069
18070 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
18071         LDKu8slice ser_ref;
18072         ser_ref.datalen = *((uint32_t*)ser);
18073         ser_ref.data = (int8_t*)(ser + 4);
18074         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18075         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
18076         return (uint64_t)ret_conv;
18077 }
18078
18079 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
18080         LDKUpdateAddHTLC obj_conv;
18081         obj_conv.inner = (void*)(obj & (~1));
18082         obj_conv.is_owned = false;
18083         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
18084         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18085         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18086         CVec_u8Z_free(ret_var);
18087         return ret_arr;
18088 }
18089
18090 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
18091         LDKu8slice ser_ref;
18092         ser_ref.datalen = *((uint32_t*)ser);
18093         ser_ref.data = (int8_t*)(ser + 4);
18094         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18095         *ret_conv = UpdateAddHTLC_read(ser_ref);
18096         return (uint64_t)ret_conv;
18097 }
18098
18099 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
18100         LDKPing obj_conv;
18101         obj_conv.inner = (void*)(obj & (~1));
18102         obj_conv.is_owned = false;
18103         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
18104         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18105         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18106         CVec_u8Z_free(ret_var);
18107         return ret_arr;
18108 }
18109
18110 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
18111         LDKu8slice ser_ref;
18112         ser_ref.datalen = *((uint32_t*)ser);
18113         ser_ref.data = (int8_t*)(ser + 4);
18114         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18115         *ret_conv = Ping_read(ser_ref);
18116         return (uint64_t)ret_conv;
18117 }
18118
18119 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
18120         LDKPong obj_conv;
18121         obj_conv.inner = (void*)(obj & (~1));
18122         obj_conv.is_owned = false;
18123         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
18124         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18125         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18126         CVec_u8Z_free(ret_var);
18127         return ret_arr;
18128 }
18129
18130 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
18131         LDKu8slice ser_ref;
18132         ser_ref.datalen = *((uint32_t*)ser);
18133         ser_ref.data = (int8_t*)(ser + 4);
18134         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18135         *ret_conv = Pong_read(ser_ref);
18136         return (uint64_t)ret_conv;
18137 }
18138
18139 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
18140         LDKUnsignedChannelAnnouncement obj_conv;
18141         obj_conv.inner = (void*)(obj & (~1));
18142         obj_conv.is_owned = false;
18143         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
18144         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18145         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18146         CVec_u8Z_free(ret_var);
18147         return ret_arr;
18148 }
18149
18150 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
18151         LDKu8slice ser_ref;
18152         ser_ref.datalen = *((uint32_t*)ser);
18153         ser_ref.data = (int8_t*)(ser + 4);
18154         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18155         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
18156         return (uint64_t)ret_conv;
18157 }
18158
18159 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
18160         LDKChannelAnnouncement obj_conv;
18161         obj_conv.inner = (void*)(obj & (~1));
18162         obj_conv.is_owned = false;
18163         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
18164         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18165         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18166         CVec_u8Z_free(ret_var);
18167         return ret_arr;
18168 }
18169
18170 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
18171         LDKu8slice ser_ref;
18172         ser_ref.datalen = *((uint32_t*)ser);
18173         ser_ref.data = (int8_t*)(ser + 4);
18174         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18175         *ret_conv = ChannelAnnouncement_read(ser_ref);
18176         return (uint64_t)ret_conv;
18177 }
18178
18179 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
18180         LDKUnsignedChannelUpdate obj_conv;
18181         obj_conv.inner = (void*)(obj & (~1));
18182         obj_conv.is_owned = false;
18183         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
18184         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18185         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18186         CVec_u8Z_free(ret_var);
18187         return ret_arr;
18188 }
18189
18190 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
18191         LDKu8slice ser_ref;
18192         ser_ref.datalen = *((uint32_t*)ser);
18193         ser_ref.data = (int8_t*)(ser + 4);
18194         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18195         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
18196         return (uint64_t)ret_conv;
18197 }
18198
18199 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
18200         LDKChannelUpdate obj_conv;
18201         obj_conv.inner = (void*)(obj & (~1));
18202         obj_conv.is_owned = false;
18203         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
18204         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18205         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18206         CVec_u8Z_free(ret_var);
18207         return ret_arr;
18208 }
18209
18210 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
18211         LDKu8slice ser_ref;
18212         ser_ref.datalen = *((uint32_t*)ser);
18213         ser_ref.data = (int8_t*)(ser + 4);
18214         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18215         *ret_conv = ChannelUpdate_read(ser_ref);
18216         return (uint64_t)ret_conv;
18217 }
18218
18219 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
18220         LDKErrorMessage obj_conv;
18221         obj_conv.inner = (void*)(obj & (~1));
18222         obj_conv.is_owned = false;
18223         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
18224         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18225         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18226         CVec_u8Z_free(ret_var);
18227         return ret_arr;
18228 }
18229
18230 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
18231         LDKu8slice ser_ref;
18232         ser_ref.datalen = *((uint32_t*)ser);
18233         ser_ref.data = (int8_t*)(ser + 4);
18234         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18235         *ret_conv = ErrorMessage_read(ser_ref);
18236         return (uint64_t)ret_conv;
18237 }
18238
18239 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
18240         LDKUnsignedNodeAnnouncement obj_conv;
18241         obj_conv.inner = (void*)(obj & (~1));
18242         obj_conv.is_owned = false;
18243         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
18244         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18245         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18246         CVec_u8Z_free(ret_var);
18247         return ret_arr;
18248 }
18249
18250 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
18251         LDKu8slice ser_ref;
18252         ser_ref.datalen = *((uint32_t*)ser);
18253         ser_ref.data = (int8_t*)(ser + 4);
18254         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18255         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
18256         return (uint64_t)ret_conv;
18257 }
18258
18259 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
18260         LDKNodeAnnouncement obj_conv;
18261         obj_conv.inner = (void*)(obj & (~1));
18262         obj_conv.is_owned = false;
18263         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
18264         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18265         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18266         CVec_u8Z_free(ret_var);
18267         return ret_arr;
18268 }
18269
18270 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
18271         LDKu8slice ser_ref;
18272         ser_ref.datalen = *((uint32_t*)ser);
18273         ser_ref.data = (int8_t*)(ser + 4);
18274         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18275         *ret_conv = NodeAnnouncement_read(ser_ref);
18276         return (uint64_t)ret_conv;
18277 }
18278
18279 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
18280         LDKu8slice ser_ref;
18281         ser_ref.datalen = *((uint32_t*)ser);
18282         ser_ref.data = (int8_t*)(ser + 4);
18283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18284         *ret_conv = QueryShortChannelIds_read(ser_ref);
18285         return (uint64_t)ret_conv;
18286 }
18287
18288 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
18289         LDKQueryShortChannelIds obj_conv;
18290         obj_conv.inner = (void*)(obj & (~1));
18291         obj_conv.is_owned = false;
18292         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
18293         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18294         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18295         CVec_u8Z_free(ret_var);
18296         return ret_arr;
18297 }
18298
18299 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
18300         LDKu8slice ser_ref;
18301         ser_ref.datalen = *((uint32_t*)ser);
18302         ser_ref.data = (int8_t*)(ser + 4);
18303         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18304         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
18305         return (uint64_t)ret_conv;
18306 }
18307
18308 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
18309         LDKReplyShortChannelIdsEnd obj_conv;
18310         obj_conv.inner = (void*)(obj & (~1));
18311         obj_conv.is_owned = false;
18312         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
18313         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18314         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18315         CVec_u8Z_free(ret_var);
18316         return ret_arr;
18317 }
18318
18319 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
18320         LDKQueryChannelRange this_arg_conv;
18321         this_arg_conv.inner = (void*)(this_arg & (~1));
18322         this_arg_conv.is_owned = false;
18323         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
18324         return ret_val;
18325 }
18326
18327 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
18328         LDKu8slice ser_ref;
18329         ser_ref.datalen = *((uint32_t*)ser);
18330         ser_ref.data = (int8_t*)(ser + 4);
18331         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18332         *ret_conv = QueryChannelRange_read(ser_ref);
18333         return (uint64_t)ret_conv;
18334 }
18335
18336 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
18337         LDKQueryChannelRange obj_conv;
18338         obj_conv.inner = (void*)(obj & (~1));
18339         obj_conv.is_owned = false;
18340         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
18341         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18342         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18343         CVec_u8Z_free(ret_var);
18344         return ret_arr;
18345 }
18346
18347 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
18348         LDKu8slice ser_ref;
18349         ser_ref.datalen = *((uint32_t*)ser);
18350         ser_ref.data = (int8_t*)(ser + 4);
18351         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18352         *ret_conv = ReplyChannelRange_read(ser_ref);
18353         return (uint64_t)ret_conv;
18354 }
18355
18356 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
18357         LDKReplyChannelRange obj_conv;
18358         obj_conv.inner = (void*)(obj & (~1));
18359         obj_conv.is_owned = false;
18360         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
18361         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18362         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18363         CVec_u8Z_free(ret_var);
18364         return ret_arr;
18365 }
18366
18367 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
18368         LDKu8slice ser_ref;
18369         ser_ref.datalen = *((uint32_t*)ser);
18370         ser_ref.data = (int8_t*)(ser + 4);
18371         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18372         *ret_conv = GossipTimestampFilter_read(ser_ref);
18373         return (uint64_t)ret_conv;
18374 }
18375
18376 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
18377         LDKGossipTimestampFilter obj_conv;
18378         obj_conv.inner = (void*)(obj & (~1));
18379         obj_conv.is_owned = false;
18380         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
18381         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18382         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18383         CVec_u8Z_free(ret_var);
18384         return ret_arr;
18385 }
18386
18387 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
18388         LDKIgnoringMessageHandler this_obj_conv;
18389         this_obj_conv.inner = (void*)(this_obj & (~1));
18390         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18391         IgnoringMessageHandler_free(this_obj_conv);
18392 }
18393
18394 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
18395         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
18396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18398         uint64_t ret_ref = (uint64_t)ret_var.inner;
18399         if (ret_var.is_owned) {
18400                 ret_ref |= 1;
18401         }
18402         return ret_ref;
18403 }
18404
18405 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18406         LDKIgnoringMessageHandler this_arg_conv;
18407         this_arg_conv.inner = (void*)(this_arg & (~1));
18408         this_arg_conv.is_owned = false;
18409         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18410         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18411         return (uint64_t)ret;
18412 }
18413
18414 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18415         LDKIgnoringMessageHandler this_arg_conv;
18416         this_arg_conv.inner = (void*)(this_arg & (~1));
18417         this_arg_conv.is_owned = false;
18418         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18419         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
18420         return (uint64_t)ret;
18421 }
18422
18423 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
18424         LDKErroringMessageHandler this_obj_conv;
18425         this_obj_conv.inner = (void*)(this_obj & (~1));
18426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18427         ErroringMessageHandler_free(this_obj_conv);
18428 }
18429
18430 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
18431         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18434         uint64_t ret_ref = (uint64_t)ret_var.inner;
18435         if (ret_var.is_owned) {
18436                 ret_ref |= 1;
18437         }
18438         return ret_ref;
18439 }
18440
18441 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18442         LDKErroringMessageHandler this_arg_conv;
18443         this_arg_conv.inner = (void*)(this_arg & (~1));
18444         this_arg_conv.is_owned = false;
18445         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18446         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18447         return (uint64_t)ret;
18448 }
18449
18450 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
18451         LDKErroringMessageHandler this_arg_conv;
18452         this_arg_conv.inner = (void*)(this_arg & (~1));
18453         this_arg_conv.is_owned = false;
18454         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18455         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18456         return (uint64_t)ret;
18457 }
18458
18459 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
18460         LDKMessageHandler this_obj_conv;
18461         this_obj_conv.inner = (void*)(this_obj & (~1));
18462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18463         MessageHandler_free(this_obj_conv);
18464 }
18465
18466 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
18467         LDKMessageHandler this_ptr_conv;
18468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18469         this_ptr_conv.is_owned = false;
18470         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
18471         return ret_ret;
18472 }
18473
18474 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
18475         LDKMessageHandler this_ptr_conv;
18476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18477         this_ptr_conv.is_owned = false;
18478         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18479         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18480 }
18481
18482 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
18483         LDKMessageHandler this_ptr_conv;
18484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18485         this_ptr_conv.is_owned = false;
18486         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
18487         return ret_ret;
18488 }
18489
18490 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
18491         LDKMessageHandler this_ptr_conv;
18492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18493         this_ptr_conv.is_owned = false;
18494         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18495         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18496 }
18497
18498 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
18499         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18500         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18501         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18504         uint64_t ret_ref = (uint64_t)ret_var.inner;
18505         if (ret_var.is_owned) {
18506                 ret_ref |= 1;
18507         }
18508         return ret_ref;
18509 }
18510
18511 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
18512         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18513         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18514         *ret = SocketDescriptor_clone(orig_conv);
18515         return (uint64_t)ret;
18516 }
18517
18518 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
18519         if ((this_ptr & 1) != 0) return;
18520         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18521         FREE((void*)this_ptr);
18522         SocketDescriptor_free(this_ptr_conv);
18523 }
18524
18525 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
18526         LDKPeerHandleError this_obj_conv;
18527         this_obj_conv.inner = (void*)(this_obj & (~1));
18528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18529         PeerHandleError_free(this_obj_conv);
18530 }
18531
18532 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
18533         LDKPeerHandleError this_ptr_conv;
18534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18535         this_ptr_conv.is_owned = false;
18536         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18537         return ret_val;
18538 }
18539
18540 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
18541         LDKPeerHandleError this_ptr_conv;
18542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18543         this_ptr_conv.is_owned = false;
18544         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18545 }
18546
18547 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
18548         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18551         uint64_t ret_ref = (uint64_t)ret_var.inner;
18552         if (ret_var.is_owned) {
18553                 ret_ref |= 1;
18554         }
18555         return ret_ref;
18556 }
18557
18558 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
18559         LDKPeerHandleError orig_conv;
18560         orig_conv.inner = (void*)(orig & (~1));
18561         orig_conv.is_owned = false;
18562         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18565         uint64_t ret_ref = (uint64_t)ret_var.inner;
18566         if (ret_var.is_owned) {
18567                 ret_ref |= 1;
18568         }
18569         return ret_ref;
18570 }
18571
18572 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
18573         LDKPeerManager this_obj_conv;
18574         this_obj_conv.inner = (void*)(this_obj & (~1));
18575         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18576         PeerManager_free(this_obj_conv);
18577 }
18578
18579 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) {
18580         LDKMessageHandler message_handler_conv;
18581         message_handler_conv.inner = (void*)(message_handler & (~1));
18582         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18583         // Warning: we need a move here but no clone is available for LDKMessageHandler
18584         LDKSecretKey our_node_secret_ref;
18585         CHECK(*((uint32_t*)our_node_secret) == 32);
18586         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
18587         unsigned char ephemeral_random_data_arr[32];
18588         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
18589         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
18590         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18591         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18592         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18595         uint64_t ret_ref = (uint64_t)ret_var.inner;
18596         if (ret_var.is_owned) {
18597                 ret_ref |= 1;
18598         }
18599         return ret_ref;
18600 }
18601
18602 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
18603         LDKPeerManager this_arg_conv;
18604         this_arg_conv.inner = (void*)(this_arg & (~1));
18605         this_arg_conv.is_owned = false;
18606         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18607         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
18608         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
18609         for (size_t m = 0; m < ret_var.datalen; m++) {
18610                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18611                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
18612                 ret_arr_ptr[m] = ret_conv_12_arr;
18613         }
18614         FREE(ret_var.data);
18615         return ret_arr;
18616 }
18617
18618 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
18619         LDKPeerManager this_arg_conv;
18620         this_arg_conv.inner = (void*)(this_arg & (~1));
18621         this_arg_conv.is_owned = false;
18622         LDKPublicKey their_node_id_ref;
18623         CHECK(*((uint32_t*)their_node_id) == 33);
18624         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
18625         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18626         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18627         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18628         return (uint64_t)ret_conv;
18629 }
18630
18631 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
18632         LDKPeerManager this_arg_conv;
18633         this_arg_conv.inner = (void*)(this_arg & (~1));
18634         this_arg_conv.is_owned = false;
18635         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18636         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18637         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18638         return (uint64_t)ret_conv;
18639 }
18640
18641 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
18642         LDKPeerManager this_arg_conv;
18643         this_arg_conv.inner = (void*)(this_arg & (~1));
18644         this_arg_conv.is_owned = false;
18645         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18646         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18647         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18648         return (uint64_t)ret_conv;
18649 }
18650
18651 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
18652         LDKPeerManager this_arg_conv;
18653         this_arg_conv.inner = (void*)(this_arg & (~1));
18654         this_arg_conv.is_owned = false;
18655         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18656         LDKu8slice data_ref;
18657         data_ref.datalen = *((uint32_t*)data);
18658         data_ref.data = (int8_t*)(data + 4);
18659         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18660         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18661         return (uint64_t)ret_conv;
18662 }
18663
18664 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
18665         LDKPeerManager this_arg_conv;
18666         this_arg_conv.inner = (void*)(this_arg & (~1));
18667         this_arg_conv.is_owned = false;
18668         PeerManager_process_events(&this_arg_conv);
18669 }
18670
18671 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
18672         LDKPeerManager this_arg_conv;
18673         this_arg_conv.inner = (void*)(this_arg & (~1));
18674         this_arg_conv.is_owned = false;
18675         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18676         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18677 }
18678
18679 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
18680         LDKPeerManager this_arg_conv;
18681         this_arg_conv.inner = (void*)(this_arg & (~1));
18682         this_arg_conv.is_owned = false;
18683         LDKPublicKey node_id_ref;
18684         CHECK(*((uint32_t*)node_id) == 33);
18685         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
18686         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18687 }
18688
18689 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
18690         LDKPeerManager this_arg_conv;
18691         this_arg_conv.inner = (void*)(this_arg & (~1));
18692         this_arg_conv.is_owned = false;
18693         PeerManager_timer_tick_occurred(&this_arg_conv);
18694 }
18695
18696 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
18697         unsigned char commitment_seed_arr[32];
18698         CHECK(*((uint32_t*)commitment_seed) == 32);
18699         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
18700         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18701         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18702         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
18703         return ret_arr;
18704 }
18705
18706 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
18707         LDKPublicKey per_commitment_point_ref;
18708         CHECK(*((uint32_t*)per_commitment_point) == 33);
18709         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18710         unsigned char base_secret_arr[32];
18711         CHECK(*((uint32_t*)base_secret) == 32);
18712         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
18713         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18714         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18715         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18716         return (uint64_t)ret_conv;
18717 }
18718
18719 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
18720         LDKPublicKey per_commitment_point_ref;
18721         CHECK(*((uint32_t*)per_commitment_point) == 33);
18722         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18723         LDKPublicKey base_point_ref;
18724         CHECK(*((uint32_t*)base_point) == 33);
18725         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
18726         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18727         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18728         return (uint64_t)ret_conv;
18729 }
18730
18731 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
18732         unsigned char per_commitment_secret_arr[32];
18733         CHECK(*((uint32_t*)per_commitment_secret) == 32);
18734         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
18735         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18736         unsigned char countersignatory_revocation_base_secret_arr[32];
18737         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
18738         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
18739         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18740         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18741         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18742         return (uint64_t)ret_conv;
18743 }
18744
18745 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
18746         LDKPublicKey per_commitment_point_ref;
18747         CHECK(*((uint32_t*)per_commitment_point) == 33);
18748         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18749         LDKPublicKey countersignatory_revocation_base_point_ref;
18750         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
18751         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
18752         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18753         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18754         return (uint64_t)ret_conv;
18755 }
18756
18757 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
18758         LDKTxCreationKeys this_obj_conv;
18759         this_obj_conv.inner = (void*)(this_obj & (~1));
18760         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18761         TxCreationKeys_free(this_obj_conv);
18762 }
18763
18764 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
18765         LDKTxCreationKeys this_ptr_conv;
18766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18767         this_ptr_conv.is_owned = false;
18768         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18769         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18770         return ret_arr;
18771 }
18772
18773 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18774         LDKTxCreationKeys this_ptr_conv;
18775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18776         this_ptr_conv.is_owned = false;
18777         LDKPublicKey val_ref;
18778         CHECK(*((uint32_t*)val) == 33);
18779         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18780         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18781 }
18782
18783 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
18784         LDKTxCreationKeys this_ptr_conv;
18785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18786         this_ptr_conv.is_owned = false;
18787         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18788         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
18789         return ret_arr;
18790 }
18791
18792 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
18793         LDKTxCreationKeys this_ptr_conv;
18794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18795         this_ptr_conv.is_owned = false;
18796         LDKPublicKey val_ref;
18797         CHECK(*((uint32_t*)val) == 33);
18798         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18799         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18800 }
18801
18802 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
18803         LDKTxCreationKeys this_ptr_conv;
18804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18805         this_ptr_conv.is_owned = false;
18806         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18807         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
18808         return ret_arr;
18809 }
18810
18811 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
18812         LDKTxCreationKeys this_ptr_conv;
18813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18814         this_ptr_conv.is_owned = false;
18815         LDKPublicKey val_ref;
18816         CHECK(*((uint32_t*)val) == 33);
18817         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18818         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18819 }
18820
18821 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
18822         LDKTxCreationKeys this_ptr_conv;
18823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18824         this_ptr_conv.is_owned = false;
18825         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18826         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
18827         return ret_arr;
18828 }
18829
18830 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
18831         LDKTxCreationKeys this_ptr_conv;
18832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18833         this_ptr_conv.is_owned = false;
18834         LDKPublicKey val_ref;
18835         CHECK(*((uint32_t*)val) == 33);
18836         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18837         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18838 }
18839
18840 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
18841         LDKTxCreationKeys this_ptr_conv;
18842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18843         this_ptr_conv.is_owned = false;
18844         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18845         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
18846         return ret_arr;
18847 }
18848
18849 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
18850         LDKTxCreationKeys this_ptr_conv;
18851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18852         this_ptr_conv.is_owned = false;
18853         LDKPublicKey val_ref;
18854         CHECK(*((uint32_t*)val) == 33);
18855         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18856         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18857 }
18858
18859 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) {
18860         LDKPublicKey per_commitment_point_arg_ref;
18861         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
18862         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
18863         LDKPublicKey revocation_key_arg_ref;
18864         CHECK(*((uint32_t*)revocation_key_arg) == 33);
18865         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
18866         LDKPublicKey broadcaster_htlc_key_arg_ref;
18867         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
18868         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
18869         LDKPublicKey countersignatory_htlc_key_arg_ref;
18870         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
18871         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
18872         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18873         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
18874         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
18875         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);
18876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18878         uint64_t ret_ref = (uint64_t)ret_var.inner;
18879         if (ret_var.is_owned) {
18880                 ret_ref |= 1;
18881         }
18882         return ret_ref;
18883 }
18884
18885 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
18886         LDKTxCreationKeys orig_conv;
18887         orig_conv.inner = (void*)(orig & (~1));
18888         orig_conv.is_owned = false;
18889         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18890         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18891         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18892         uint64_t ret_ref = (uint64_t)ret_var.inner;
18893         if (ret_var.is_owned) {
18894                 ret_ref |= 1;
18895         }
18896         return ret_ref;
18897 }
18898
18899 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
18900         LDKTxCreationKeys obj_conv;
18901         obj_conv.inner = (void*)(obj & (~1));
18902         obj_conv.is_owned = false;
18903         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18904         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18905         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18906         CVec_u8Z_free(ret_var);
18907         return ret_arr;
18908 }
18909
18910 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
18911         LDKu8slice ser_ref;
18912         ser_ref.datalen = *((uint32_t*)ser);
18913         ser_ref.data = (int8_t*)(ser + 4);
18914         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18915         *ret_conv = TxCreationKeys_read(ser_ref);
18916         return (uint64_t)ret_conv;
18917 }
18918
18919 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
18920         LDKChannelPublicKeys this_obj_conv;
18921         this_obj_conv.inner = (void*)(this_obj & (~1));
18922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18923         ChannelPublicKeys_free(this_obj_conv);
18924 }
18925
18926 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
18927         LDKChannelPublicKeys this_ptr_conv;
18928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18929         this_ptr_conv.is_owned = false;
18930         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18931         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
18932         return ret_arr;
18933 }
18934
18935 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
18936         LDKChannelPublicKeys this_ptr_conv;
18937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18938         this_ptr_conv.is_owned = false;
18939         LDKPublicKey val_ref;
18940         CHECK(*((uint32_t*)val) == 33);
18941         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18942         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18943 }
18944
18945 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
18946         LDKChannelPublicKeys this_ptr_conv;
18947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18948         this_ptr_conv.is_owned = false;
18949         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18950         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
18951         return ret_arr;
18952 }
18953
18954 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
18955         LDKChannelPublicKeys this_ptr_conv;
18956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18957         this_ptr_conv.is_owned = false;
18958         LDKPublicKey val_ref;
18959         CHECK(*((uint32_t*)val) == 33);
18960         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18961         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18962 }
18963
18964 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
18965         LDKChannelPublicKeys this_ptr_conv;
18966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18967         this_ptr_conv.is_owned = false;
18968         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18969         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
18970         return ret_arr;
18971 }
18972
18973 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
18974         LDKChannelPublicKeys this_ptr_conv;
18975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18976         this_ptr_conv.is_owned = false;
18977         LDKPublicKey val_ref;
18978         CHECK(*((uint32_t*)val) == 33);
18979         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18980         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18981 }
18982
18983 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
18984         LDKChannelPublicKeys this_ptr_conv;
18985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18986         this_ptr_conv.is_owned = false;
18987         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18988         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
18989         return ret_arr;
18990 }
18991
18992 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
18993         LDKChannelPublicKeys this_ptr_conv;
18994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18995         this_ptr_conv.is_owned = false;
18996         LDKPublicKey val_ref;
18997         CHECK(*((uint32_t*)val) == 33);
18998         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18999         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
19000 }
19001
19002 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
19003         LDKChannelPublicKeys this_ptr_conv;
19004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19005         this_ptr_conv.is_owned = false;
19006         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19007         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
19008         return ret_arr;
19009 }
19010
19011 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
19012         LDKChannelPublicKeys this_ptr_conv;
19013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19014         this_ptr_conv.is_owned = false;
19015         LDKPublicKey val_ref;
19016         CHECK(*((uint32_t*)val) == 33);
19017         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19018         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
19019 }
19020
19021 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) {
19022         LDKPublicKey funding_pubkey_arg_ref;
19023         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
19024         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
19025         LDKPublicKey revocation_basepoint_arg_ref;
19026         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
19027         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
19028         LDKPublicKey payment_point_arg_ref;
19029         CHECK(*((uint32_t*)payment_point_arg) == 33);
19030         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
19031         LDKPublicKey delayed_payment_basepoint_arg_ref;
19032         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
19033         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
19034         LDKPublicKey htlc_basepoint_arg_ref;
19035         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
19036         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
19037         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);
19038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19040         uint64_t ret_ref = (uint64_t)ret_var.inner;
19041         if (ret_var.is_owned) {
19042                 ret_ref |= 1;
19043         }
19044         return ret_ref;
19045 }
19046
19047 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
19048         LDKChannelPublicKeys orig_conv;
19049         orig_conv.inner = (void*)(orig & (~1));
19050         orig_conv.is_owned = false;
19051         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
19052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19054         uint64_t ret_ref = (uint64_t)ret_var.inner;
19055         if (ret_var.is_owned) {
19056                 ret_ref |= 1;
19057         }
19058         return ret_ref;
19059 }
19060
19061 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
19062         LDKChannelPublicKeys obj_conv;
19063         obj_conv.inner = (void*)(obj & (~1));
19064         obj_conv.is_owned = false;
19065         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
19066         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19067         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19068         CVec_u8Z_free(ret_var);
19069         return ret_arr;
19070 }
19071
19072 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
19073         LDKu8slice ser_ref;
19074         ser_ref.datalen = *((uint32_t*)ser);
19075         ser_ref.data = (int8_t*)(ser + 4);
19076         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
19077         *ret_conv = ChannelPublicKeys_read(ser_ref);
19078         return (uint64_t)ret_conv;
19079 }
19080
19081 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) {
19082         LDKPublicKey per_commitment_point_ref;
19083         CHECK(*((uint32_t*)per_commitment_point) == 33);
19084         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19085         LDKPublicKey broadcaster_delayed_payment_base_ref;
19086         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
19087         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
19088         LDKPublicKey broadcaster_htlc_base_ref;
19089         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
19090         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
19091         LDKPublicKey countersignatory_revocation_base_ref;
19092         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
19093         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
19094         LDKPublicKey countersignatory_htlc_base_ref;
19095         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
19096         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
19097         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
19098         *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);
19099         return (uint64_t)ret_conv;
19100 }
19101
19102 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
19103         LDKPublicKey per_commitment_point_ref;
19104         CHECK(*((uint32_t*)per_commitment_point) == 33);
19105         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
19106         LDKChannelPublicKeys broadcaster_keys_conv;
19107         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19108         broadcaster_keys_conv.is_owned = false;
19109         LDKChannelPublicKeys countersignatory_keys_conv;
19110         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19111         countersignatory_keys_conv.is_owned = false;
19112         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
19113         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
19114         return (uint64_t)ret_conv;
19115 }
19116
19117 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
19118         LDKPublicKey revocation_key_ref;
19119         CHECK(*((uint32_t*)revocation_key) == 33);
19120         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19121         LDKPublicKey broadcaster_delayed_payment_key_ref;
19122         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19123         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19124         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
19125         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19126         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19127         CVec_u8Z_free(ret_var);
19128         return ret_arr;
19129 }
19130
19131 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
19132         LDKHTLCOutputInCommitment this_obj_conv;
19133         this_obj_conv.inner = (void*)(this_obj & (~1));
19134         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19135         HTLCOutputInCommitment_free(this_obj_conv);
19136 }
19137
19138 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
19139         LDKHTLCOutputInCommitment this_ptr_conv;
19140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19141         this_ptr_conv.is_owned = false;
19142         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
19143         return ret_val;
19144 }
19145
19146 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
19147         LDKHTLCOutputInCommitment this_ptr_conv;
19148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19149         this_ptr_conv.is_owned = false;
19150         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
19151 }
19152
19153 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
19154         LDKHTLCOutputInCommitment this_ptr_conv;
19155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19156         this_ptr_conv.is_owned = false;
19157         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
19158         return ret_val;
19159 }
19160
19161 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
19162         LDKHTLCOutputInCommitment this_ptr_conv;
19163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19164         this_ptr_conv.is_owned = false;
19165         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
19166 }
19167
19168 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
19169         LDKHTLCOutputInCommitment this_ptr_conv;
19170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19171         this_ptr_conv.is_owned = false;
19172         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
19173         return ret_val;
19174 }
19175
19176 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
19177         LDKHTLCOutputInCommitment this_ptr_conv;
19178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19179         this_ptr_conv.is_owned = false;
19180         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
19181 }
19182
19183 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
19184         LDKHTLCOutputInCommitment this_ptr_conv;
19185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19186         this_ptr_conv.is_owned = false;
19187         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19188         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
19189         return ret_arr;
19190 }
19191
19192 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
19193         LDKHTLCOutputInCommitment this_ptr_conv;
19194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19195         this_ptr_conv.is_owned = false;
19196         LDKThirtyTwoBytes val_ref;
19197         CHECK(*((uint32_t*)val) == 32);
19198         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19199         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
19200 }
19201
19202 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
19203         LDKHTLCOutputInCommitment this_ptr_conv;
19204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19205         this_ptr_conv.is_owned = false;
19206         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
19207         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
19208         uint64_t ret_ref = (uint64_t)ret_copy;
19209         return ret_ref;
19210 }
19211
19212 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
19213         LDKHTLCOutputInCommitment this_ptr_conv;
19214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19215         this_ptr_conv.is_owned = false;
19216         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
19217         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
19218 }
19219
19220 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) {
19221         LDKThirtyTwoBytes payment_hash_arg_ref;
19222         CHECK(*((uint32_t*)payment_hash_arg) == 32);
19223         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
19224         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
19225         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
19226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19228         uint64_t ret_ref = (uint64_t)ret_var.inner;
19229         if (ret_var.is_owned) {
19230                 ret_ref |= 1;
19231         }
19232         return ret_ref;
19233 }
19234
19235 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
19236         LDKHTLCOutputInCommitment orig_conv;
19237         orig_conv.inner = (void*)(orig & (~1));
19238         orig_conv.is_owned = false;
19239         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
19240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19242         uint64_t ret_ref = (uint64_t)ret_var.inner;
19243         if (ret_var.is_owned) {
19244                 ret_ref |= 1;
19245         }
19246         return ret_ref;
19247 }
19248
19249 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
19250         LDKHTLCOutputInCommitment obj_conv;
19251         obj_conv.inner = (void*)(obj & (~1));
19252         obj_conv.is_owned = false;
19253         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
19254         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19255         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19256         CVec_u8Z_free(ret_var);
19257         return ret_arr;
19258 }
19259
19260 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
19261         LDKu8slice ser_ref;
19262         ser_ref.datalen = *((uint32_t*)ser);
19263         ser_ref.data = (int8_t*)(ser + 4);
19264         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
19265         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
19266         return (uint64_t)ret_conv;
19267 }
19268
19269 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
19270         LDKHTLCOutputInCommitment htlc_conv;
19271         htlc_conv.inner = (void*)(htlc & (~1));
19272         htlc_conv.is_owned = false;
19273         LDKTxCreationKeys keys_conv;
19274         keys_conv.inner = (void*)(keys & (~1));
19275         keys_conv.is_owned = false;
19276         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
19277         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19278         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19279         CVec_u8Z_free(ret_var);
19280         return ret_arr;
19281 }
19282
19283 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
19284         LDKPublicKey broadcaster_ref;
19285         CHECK(*((uint32_t*)broadcaster) == 33);
19286         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
19287         LDKPublicKey countersignatory_ref;
19288         CHECK(*((uint32_t*)countersignatory) == 33);
19289         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
19290         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
19291         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19292         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19293         CVec_u8Z_free(ret_var);
19294         return ret_arr;
19295 }
19296
19297 int8_tArray  __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
19298         unsigned char commitment_txid_arr[32];
19299         CHECK(*((uint32_t*)commitment_txid) == 32);
19300         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
19301         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
19302         LDKHTLCOutputInCommitment htlc_conv;
19303         htlc_conv.inner = (void*)(htlc & (~1));
19304         htlc_conv.is_owned = false;
19305         LDKPublicKey broadcaster_delayed_payment_key_ref;
19306         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19307         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19308         LDKPublicKey revocation_key_ref;
19309         CHECK(*((uint32_t*)revocation_key) == 33);
19310         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19311         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
19312         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19313         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19314         Transaction_free(ret_var);
19315         return ret_arr;
19316 }
19317
19318 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
19319         LDKChannelTransactionParameters this_obj_conv;
19320         this_obj_conv.inner = (void*)(this_obj & (~1));
19321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19322         ChannelTransactionParameters_free(this_obj_conv);
19323 }
19324
19325 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
19326         LDKChannelTransactionParameters this_ptr_conv;
19327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19328         this_ptr_conv.is_owned = false;
19329         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
19330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19332         uint64_t ret_ref = (uint64_t)ret_var.inner;
19333         if (ret_var.is_owned) {
19334                 ret_ref |= 1;
19335         }
19336         return ret_ref;
19337 }
19338
19339 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
19340         LDKChannelTransactionParameters this_ptr_conv;
19341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19342         this_ptr_conv.is_owned = false;
19343         LDKChannelPublicKeys val_conv;
19344         val_conv.inner = (void*)(val & (~1));
19345         val_conv.is_owned = (val & 1) || (val == 0);
19346         val_conv = ChannelPublicKeys_clone(&val_conv);
19347         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
19348 }
19349
19350 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
19351         LDKChannelTransactionParameters this_ptr_conv;
19352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19353         this_ptr_conv.is_owned = false;
19354         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
19355         return ret_val;
19356 }
19357
19358 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19359         LDKChannelTransactionParameters this_ptr_conv;
19360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19361         this_ptr_conv.is_owned = false;
19362         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
19363 }
19364
19365 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
19366         LDKChannelTransactionParameters this_ptr_conv;
19367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19368         this_ptr_conv.is_owned = false;
19369         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
19370         return ret_val;
19371 }
19372
19373 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
19374         LDKChannelTransactionParameters this_ptr_conv;
19375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19376         this_ptr_conv.is_owned = false;
19377         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
19378 }
19379
19380 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
19381         LDKChannelTransactionParameters this_ptr_conv;
19382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19383         this_ptr_conv.is_owned = false;
19384         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
19385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19387         uint64_t ret_ref = (uint64_t)ret_var.inner;
19388         if (ret_var.is_owned) {
19389                 ret_ref |= 1;
19390         }
19391         return ret_ref;
19392 }
19393
19394 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
19395         LDKChannelTransactionParameters this_ptr_conv;
19396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19397         this_ptr_conv.is_owned = false;
19398         LDKCounterpartyChannelTransactionParameters val_conv;
19399         val_conv.inner = (void*)(val & (~1));
19400         val_conv.is_owned = (val & 1) || (val == 0);
19401         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19402         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19403 }
19404
19405 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
19406         LDKChannelTransactionParameters this_ptr_conv;
19407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19408         this_ptr_conv.is_owned = false;
19409         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19412         uint64_t ret_ref = (uint64_t)ret_var.inner;
19413         if (ret_var.is_owned) {
19414                 ret_ref |= 1;
19415         }
19416         return ret_ref;
19417 }
19418
19419 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
19420         LDKChannelTransactionParameters this_ptr_conv;
19421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19422         this_ptr_conv.is_owned = false;
19423         LDKOutPoint val_conv;
19424         val_conv.inner = (void*)(val & (~1));
19425         val_conv.is_owned = (val & 1) || (val == 0);
19426         val_conv = OutPoint_clone(&val_conv);
19427         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19428 }
19429
19430 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) {
19431         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19432         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19433         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19434         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19435         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19436         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19437         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19438         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19439         LDKOutPoint funding_outpoint_arg_conv;
19440         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19441         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19442         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19443         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);
19444         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19445         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19446         uint64_t ret_ref = (uint64_t)ret_var.inner;
19447         if (ret_var.is_owned) {
19448                 ret_ref |= 1;
19449         }
19450         return ret_ref;
19451 }
19452
19453 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
19454         LDKChannelTransactionParameters orig_conv;
19455         orig_conv.inner = (void*)(orig & (~1));
19456         orig_conv.is_owned = false;
19457         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19460         uint64_t ret_ref = (uint64_t)ret_var.inner;
19461         if (ret_var.is_owned) {
19462                 ret_ref |= 1;
19463         }
19464         return ret_ref;
19465 }
19466
19467 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
19468         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19469         this_obj_conv.inner = (void*)(this_obj & (~1));
19470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19471         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19472 }
19473
19474 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
19475         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19477         this_ptr_conv.is_owned = false;
19478         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19481         uint64_t ret_ref = (uint64_t)ret_var.inner;
19482         if (ret_var.is_owned) {
19483                 ret_ref |= 1;
19484         }
19485         return ret_ref;
19486 }
19487
19488 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
19489         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19491         this_ptr_conv.is_owned = false;
19492         LDKChannelPublicKeys val_conv;
19493         val_conv.inner = (void*)(val & (~1));
19494         val_conv.is_owned = (val & 1) || (val == 0);
19495         val_conv = ChannelPublicKeys_clone(&val_conv);
19496         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19497 }
19498
19499 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
19500         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19502         this_ptr_conv.is_owned = false;
19503         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19504         return ret_val;
19505 }
19506
19507 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19508         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19510         this_ptr_conv.is_owned = false;
19511         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19512 }
19513
19514 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
19515         LDKChannelPublicKeys pubkeys_arg_conv;
19516         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19517         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19518         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19519         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19522         uint64_t ret_ref = (uint64_t)ret_var.inner;
19523         if (ret_var.is_owned) {
19524                 ret_ref |= 1;
19525         }
19526         return ret_ref;
19527 }
19528
19529 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
19530         LDKCounterpartyChannelTransactionParameters orig_conv;
19531         orig_conv.inner = (void*)(orig & (~1));
19532         orig_conv.is_owned = false;
19533         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19534         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19535         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19536         uint64_t ret_ref = (uint64_t)ret_var.inner;
19537         if (ret_var.is_owned) {
19538                 ret_ref |= 1;
19539         }
19540         return ret_ref;
19541 }
19542
19543 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
19544         LDKChannelTransactionParameters this_arg_conv;
19545         this_arg_conv.inner = (void*)(this_arg & (~1));
19546         this_arg_conv.is_owned = false;
19547         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19548         return ret_val;
19549 }
19550
19551 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
19552         LDKChannelTransactionParameters this_arg_conv;
19553         this_arg_conv.inner = (void*)(this_arg & (~1));
19554         this_arg_conv.is_owned = false;
19555         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19558         uint64_t ret_ref = (uint64_t)ret_var.inner;
19559         if (ret_var.is_owned) {
19560                 ret_ref |= 1;
19561         }
19562         return ret_ref;
19563 }
19564
19565 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
19566         LDKChannelTransactionParameters this_arg_conv;
19567         this_arg_conv.inner = (void*)(this_arg & (~1));
19568         this_arg_conv.is_owned = false;
19569         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19572         uint64_t ret_ref = (uint64_t)ret_var.inner;
19573         if (ret_var.is_owned) {
19574                 ret_ref |= 1;
19575         }
19576         return ret_ref;
19577 }
19578
19579 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
19580         LDKCounterpartyChannelTransactionParameters obj_conv;
19581         obj_conv.inner = (void*)(obj & (~1));
19582         obj_conv.is_owned = false;
19583         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19584         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19585         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19586         CVec_u8Z_free(ret_var);
19587         return ret_arr;
19588 }
19589
19590 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
19591         LDKu8slice ser_ref;
19592         ser_ref.datalen = *((uint32_t*)ser);
19593         ser_ref.data = (int8_t*)(ser + 4);
19594         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19595         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19596         return (uint64_t)ret_conv;
19597 }
19598
19599 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
19600         LDKChannelTransactionParameters obj_conv;
19601         obj_conv.inner = (void*)(obj & (~1));
19602         obj_conv.is_owned = false;
19603         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19604         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19605         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19606         CVec_u8Z_free(ret_var);
19607         return ret_arr;
19608 }
19609
19610 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
19611         LDKu8slice ser_ref;
19612         ser_ref.datalen = *((uint32_t*)ser);
19613         ser_ref.data = (int8_t*)(ser + 4);
19614         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19615         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19616         return (uint64_t)ret_conv;
19617 }
19618
19619 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
19620         LDKDirectedChannelTransactionParameters this_obj_conv;
19621         this_obj_conv.inner = (void*)(this_obj & (~1));
19622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19623         DirectedChannelTransactionParameters_free(this_obj_conv);
19624 }
19625
19626 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
19627         LDKDirectedChannelTransactionParameters this_arg_conv;
19628         this_arg_conv.inner = (void*)(this_arg & (~1));
19629         this_arg_conv.is_owned = false;
19630         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19633         uint64_t ret_ref = (uint64_t)ret_var.inner;
19634         if (ret_var.is_owned) {
19635                 ret_ref |= 1;
19636         }
19637         return ret_ref;
19638 }
19639
19640 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
19641         LDKDirectedChannelTransactionParameters this_arg_conv;
19642         this_arg_conv.inner = (void*)(this_arg & (~1));
19643         this_arg_conv.is_owned = false;
19644         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19647         uint64_t ret_ref = (uint64_t)ret_var.inner;
19648         if (ret_var.is_owned) {
19649                 ret_ref |= 1;
19650         }
19651         return ret_ref;
19652 }
19653
19654 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
19655         LDKDirectedChannelTransactionParameters this_arg_conv;
19656         this_arg_conv.inner = (void*)(this_arg & (~1));
19657         this_arg_conv.is_owned = false;
19658         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19659         return ret_val;
19660 }
19661
19662 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
19663         LDKDirectedChannelTransactionParameters this_arg_conv;
19664         this_arg_conv.inner = (void*)(this_arg & (~1));
19665         this_arg_conv.is_owned = false;
19666         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19667         return ret_val;
19668 }
19669
19670 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
19671         LDKDirectedChannelTransactionParameters this_arg_conv;
19672         this_arg_conv.inner = (void*)(this_arg & (~1));
19673         this_arg_conv.is_owned = false;
19674         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19677         uint64_t ret_ref = (uint64_t)ret_var.inner;
19678         if (ret_var.is_owned) {
19679                 ret_ref |= 1;
19680         }
19681         return ret_ref;
19682 }
19683
19684 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
19685         LDKHolderCommitmentTransaction this_obj_conv;
19686         this_obj_conv.inner = (void*)(this_obj & (~1));
19687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19688         HolderCommitmentTransaction_free(this_obj_conv);
19689 }
19690
19691 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
19692         LDKHolderCommitmentTransaction this_ptr_conv;
19693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19694         this_ptr_conv.is_owned = false;
19695         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19696         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
19697         return ret_arr;
19698 }
19699
19700 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
19701         LDKHolderCommitmentTransaction this_ptr_conv;
19702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19703         this_ptr_conv.is_owned = false;
19704         LDKSignature val_ref;
19705         CHECK(*((uint32_t*)val) == 64);
19706         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19707         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19708 }
19709
19710 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
19711         LDKHolderCommitmentTransaction this_ptr_conv;
19712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19713         this_ptr_conv.is_owned = false;
19714         LDKCVec_SignatureZ val_constr;
19715         val_constr.datalen = *((uint32_t*)val);
19716         if (val_constr.datalen > 0)
19717                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19718         else
19719                 val_constr.data = NULL;
19720         int8_tArray* val_vals = (int8_tArray*)(val + 4);
19721         for (size_t m = 0; m < val_constr.datalen; m++) {
19722                 int8_tArray val_conv_12 = val_vals[m];
19723                 LDKSignature val_conv_12_ref;
19724                 CHECK(*((uint32_t*)val_conv_12) == 64);
19725                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
19726                 val_constr.data[m] = val_conv_12_ref;
19727         }
19728         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19729 }
19730
19731 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
19732         LDKHolderCommitmentTransaction orig_conv;
19733         orig_conv.inner = (void*)(orig & (~1));
19734         orig_conv.is_owned = false;
19735         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19736         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19737         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19738         uint64_t ret_ref = (uint64_t)ret_var.inner;
19739         if (ret_var.is_owned) {
19740                 ret_ref |= 1;
19741         }
19742         return ret_ref;
19743 }
19744
19745 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
19746         LDKHolderCommitmentTransaction obj_conv;
19747         obj_conv.inner = (void*)(obj & (~1));
19748         obj_conv.is_owned = false;
19749         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19750         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19751         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19752         CVec_u8Z_free(ret_var);
19753         return ret_arr;
19754 }
19755
19756 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
19757         LDKu8slice ser_ref;
19758         ser_ref.datalen = *((uint32_t*)ser);
19759         ser_ref.data = (int8_t*)(ser + 4);
19760         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19761         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19762         return (uint64_t)ret_conv;
19763 }
19764
19765 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) {
19766         LDKCommitmentTransaction commitment_tx_conv;
19767         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19768         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19769         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19770         LDKSignature counterparty_sig_ref;
19771         CHECK(*((uint32_t*)counterparty_sig) == 64);
19772         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
19773         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19774         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
19775         if (counterparty_htlc_sigs_constr.datalen > 0)
19776                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19777         else
19778                 counterparty_htlc_sigs_constr.data = NULL;
19779         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
19780         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
19781                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
19782                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
19783                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
19784                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
19785                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
19786         }
19787         LDKPublicKey holder_funding_key_ref;
19788         CHECK(*((uint32_t*)holder_funding_key) == 33);
19789         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
19790         LDKPublicKey counterparty_funding_key_ref;
19791         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
19792         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
19793         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19794         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19795         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19796         uint64_t ret_ref = (uint64_t)ret_var.inner;
19797         if (ret_var.is_owned) {
19798                 ret_ref |= 1;
19799         }
19800         return ret_ref;
19801 }
19802
19803 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
19804         LDKBuiltCommitmentTransaction this_obj_conv;
19805         this_obj_conv.inner = (void*)(this_obj & (~1));
19806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19807         BuiltCommitmentTransaction_free(this_obj_conv);
19808 }
19809
19810 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
19811         LDKBuiltCommitmentTransaction this_ptr_conv;
19812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19813         this_ptr_conv.is_owned = false;
19814         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19815         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19816         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19817         Transaction_free(ret_var);
19818         return ret_arr;
19819 }
19820
19821 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
19822         LDKBuiltCommitmentTransaction this_ptr_conv;
19823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19824         this_ptr_conv.is_owned = false;
19825         LDKTransaction val_ref;
19826         val_ref.datalen = *((uint32_t*)val);
19827         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19828         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
19829         val_ref.data_is_owned = true;
19830         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19831 }
19832
19833 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
19834         LDKBuiltCommitmentTransaction this_ptr_conv;
19835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19836         this_ptr_conv.is_owned = false;
19837         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19838         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
19839         return ret_arr;
19840 }
19841
19842 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
19843         LDKBuiltCommitmentTransaction this_ptr_conv;
19844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19845         this_ptr_conv.is_owned = false;
19846         LDKThirtyTwoBytes val_ref;
19847         CHECK(*((uint32_t*)val) == 32);
19848         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19849         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19850 }
19851
19852 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
19853         LDKTransaction transaction_arg_ref;
19854         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
19855         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19856         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
19857         transaction_arg_ref.data_is_owned = true;
19858         LDKThirtyTwoBytes txid_arg_ref;
19859         CHECK(*((uint32_t*)txid_arg) == 32);
19860         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19861         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19864         uint64_t ret_ref = (uint64_t)ret_var.inner;
19865         if (ret_var.is_owned) {
19866                 ret_ref |= 1;
19867         }
19868         return ret_ref;
19869 }
19870
19871 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
19872         LDKBuiltCommitmentTransaction orig_conv;
19873         orig_conv.inner = (void*)(orig & (~1));
19874         orig_conv.is_owned = false;
19875         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19878         uint64_t ret_ref = (uint64_t)ret_var.inner;
19879         if (ret_var.is_owned) {
19880                 ret_ref |= 1;
19881         }
19882         return ret_ref;
19883 }
19884
19885 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
19886         LDKBuiltCommitmentTransaction obj_conv;
19887         obj_conv.inner = (void*)(obj & (~1));
19888         obj_conv.is_owned = false;
19889         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19890         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19891         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19892         CVec_u8Z_free(ret_var);
19893         return ret_arr;
19894 }
19895
19896 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
19897         LDKu8slice ser_ref;
19898         ser_ref.datalen = *((uint32_t*)ser);
19899         ser_ref.data = (int8_t*)(ser + 4);
19900         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19901         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19902         return (uint64_t)ret_conv;
19903 }
19904
19905 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
19906         LDKBuiltCommitmentTransaction this_arg_conv;
19907         this_arg_conv.inner = (void*)(this_arg & (~1));
19908         this_arg_conv.is_owned = false;
19909         LDKu8slice funding_redeemscript_ref;
19910         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19911         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19912         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19913         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
19914         return ret_arr;
19915 }
19916
19917 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) {
19918         LDKBuiltCommitmentTransaction this_arg_conv;
19919         this_arg_conv.inner = (void*)(this_arg & (~1));
19920         this_arg_conv.is_owned = false;
19921         unsigned char funding_key_arr[32];
19922         CHECK(*((uint32_t*)funding_key) == 32);
19923         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
19924         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19925         LDKu8slice funding_redeemscript_ref;
19926         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19927         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19928         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19929         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
19930         return ret_arr;
19931 }
19932
19933 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
19934         LDKCommitmentTransaction this_obj_conv;
19935         this_obj_conv.inner = (void*)(this_obj & (~1));
19936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19937         CommitmentTransaction_free(this_obj_conv);
19938 }
19939
19940 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
19941         LDKCommitmentTransaction orig_conv;
19942         orig_conv.inner = (void*)(orig & (~1));
19943         orig_conv.is_owned = false;
19944         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19947         uint64_t ret_ref = (uint64_t)ret_var.inner;
19948         if (ret_var.is_owned) {
19949                 ret_ref |= 1;
19950         }
19951         return ret_ref;
19952 }
19953
19954 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
19955         LDKCommitmentTransaction obj_conv;
19956         obj_conv.inner = (void*)(obj & (~1));
19957         obj_conv.is_owned = false;
19958         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19959         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19960         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19961         CVec_u8Z_free(ret_var);
19962         return ret_arr;
19963 }
19964
19965 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
19966         LDKu8slice ser_ref;
19967         ser_ref.datalen = *((uint32_t*)ser);
19968         ser_ref.data = (int8_t*)(ser + 4);
19969         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19970         *ret_conv = CommitmentTransaction_read(ser_ref);
19971         return (uint64_t)ret_conv;
19972 }
19973
19974 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
19975         LDKCommitmentTransaction this_arg_conv;
19976         this_arg_conv.inner = (void*)(this_arg & (~1));
19977         this_arg_conv.is_owned = false;
19978         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19979         return ret_val;
19980 }
19981
19982 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
19983         LDKCommitmentTransaction this_arg_conv;
19984         this_arg_conv.inner = (void*)(this_arg & (~1));
19985         this_arg_conv.is_owned = false;
19986         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19987         return ret_val;
19988 }
19989
19990 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
19991         LDKCommitmentTransaction this_arg_conv;
19992         this_arg_conv.inner = (void*)(this_arg & (~1));
19993         this_arg_conv.is_owned = false;
19994         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19995         return ret_val;
19996 }
19997
19998 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
19999         LDKCommitmentTransaction this_arg_conv;
20000         this_arg_conv.inner = (void*)(this_arg & (~1));
20001         this_arg_conv.is_owned = false;
20002         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
20003         return ret_val;
20004 }
20005
20006 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
20007         LDKCommitmentTransaction this_arg_conv;
20008         this_arg_conv.inner = (void*)(this_arg & (~1));
20009         this_arg_conv.is_owned = false;
20010         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
20011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20013         uint64_t ret_ref = (uint64_t)ret_var.inner;
20014         if (ret_var.is_owned) {
20015                 ret_ref |= 1;
20016         }
20017         return ret_ref;
20018 }
20019
20020 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
20021         LDKCommitmentTransaction this_arg_conv;
20022         this_arg_conv.inner = (void*)(this_arg & (~1));
20023         this_arg_conv.is_owned = false;
20024         LDKDirectedChannelTransactionParameters channel_parameters_conv;
20025         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
20026         channel_parameters_conv.is_owned = false;
20027         LDKChannelPublicKeys broadcaster_keys_conv;
20028         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
20029         broadcaster_keys_conv.is_owned = false;
20030         LDKChannelPublicKeys countersignatory_keys_conv;
20031         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
20032         countersignatory_keys_conv.is_owned = false;
20033         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
20034         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
20035         return (uint64_t)ret_conv;
20036 }
20037
20038 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
20039         LDKTrustedCommitmentTransaction this_obj_conv;
20040         this_obj_conv.inner = (void*)(this_obj & (~1));
20041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20042         TrustedCommitmentTransaction_free(this_obj_conv);
20043 }
20044
20045 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
20046         LDKTrustedCommitmentTransaction this_arg_conv;
20047         this_arg_conv.inner = (void*)(this_arg & (~1));
20048         this_arg_conv.is_owned = false;
20049         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20050         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
20051         return ret_arr;
20052 }
20053
20054 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
20055         LDKTrustedCommitmentTransaction this_arg_conv;
20056         this_arg_conv.inner = (void*)(this_arg & (~1));
20057         this_arg_conv.is_owned = false;
20058         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
20059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20061         uint64_t ret_ref = (uint64_t)ret_var.inner;
20062         if (ret_var.is_owned) {
20063                 ret_ref |= 1;
20064         }
20065         return ret_ref;
20066 }
20067
20068 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
20069         LDKTrustedCommitmentTransaction this_arg_conv;
20070         this_arg_conv.inner = (void*)(this_arg & (~1));
20071         this_arg_conv.is_owned = false;
20072         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
20073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20075         uint64_t ret_ref = (uint64_t)ret_var.inner;
20076         if (ret_var.is_owned) {
20077                 ret_ref |= 1;
20078         }
20079         return ret_ref;
20080 }
20081
20082 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
20083         LDKTrustedCommitmentTransaction this_arg_conv;
20084         this_arg_conv.inner = (void*)(this_arg & (~1));
20085         this_arg_conv.is_owned = false;
20086         unsigned char htlc_base_key_arr[32];
20087         CHECK(*((uint32_t*)htlc_base_key) == 32);
20088         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
20089         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
20090         LDKDirectedChannelTransactionParameters channel_parameters_conv;
20091         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
20092         channel_parameters_conv.is_owned = false;
20093         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
20094         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
20095         return (uint64_t)ret_conv;
20096 }
20097
20098 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) {
20099         LDKPublicKey broadcaster_payment_basepoint_ref;
20100         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
20101         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
20102         LDKPublicKey countersignatory_payment_basepoint_ref;
20103         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
20104         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
20105         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
20106         return ret_val;
20107 }
20108
20109 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
20110         LDKInitFeatures a_conv;
20111         a_conv.inner = (void*)(a & (~1));
20112         a_conv.is_owned = false;
20113         LDKInitFeatures b_conv;
20114         b_conv.inner = (void*)(b & (~1));
20115         b_conv.is_owned = false;
20116         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
20117         return ret_val;
20118 }
20119
20120 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
20121         LDKNodeFeatures a_conv;
20122         a_conv.inner = (void*)(a & (~1));
20123         a_conv.is_owned = false;
20124         LDKNodeFeatures b_conv;
20125         b_conv.inner = (void*)(b & (~1));
20126         b_conv.is_owned = false;
20127         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
20128         return ret_val;
20129 }
20130
20131 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
20132         LDKChannelFeatures a_conv;
20133         a_conv.inner = (void*)(a & (~1));
20134         a_conv.is_owned = false;
20135         LDKChannelFeatures b_conv;
20136         b_conv.inner = (void*)(b & (~1));
20137         b_conv.is_owned = false;
20138         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
20139         return ret_val;
20140 }
20141
20142 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
20143         LDKInvoiceFeatures a_conv;
20144         a_conv.inner = (void*)(a & (~1));
20145         a_conv.is_owned = false;
20146         LDKInvoiceFeatures b_conv;
20147         b_conv.inner = (void*)(b & (~1));
20148         b_conv.is_owned = false;
20149         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
20150         return ret_val;
20151 }
20152
20153 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
20154         LDKInitFeatures orig_conv;
20155         orig_conv.inner = (void*)(orig & (~1));
20156         orig_conv.is_owned = false;
20157         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
20158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20160         uint64_t ret_ref = (uint64_t)ret_var.inner;
20161         if (ret_var.is_owned) {
20162                 ret_ref |= 1;
20163         }
20164         return ret_ref;
20165 }
20166
20167 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
20168         LDKNodeFeatures orig_conv;
20169         orig_conv.inner = (void*)(orig & (~1));
20170         orig_conv.is_owned = false;
20171         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
20172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20174         uint64_t ret_ref = (uint64_t)ret_var.inner;
20175         if (ret_var.is_owned) {
20176                 ret_ref |= 1;
20177         }
20178         return ret_ref;
20179 }
20180
20181 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
20182         LDKChannelFeatures orig_conv;
20183         orig_conv.inner = (void*)(orig & (~1));
20184         orig_conv.is_owned = false;
20185         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
20186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20188         uint64_t ret_ref = (uint64_t)ret_var.inner;
20189         if (ret_var.is_owned) {
20190                 ret_ref |= 1;
20191         }
20192         return ret_ref;
20193 }
20194
20195 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
20196         LDKInvoiceFeatures orig_conv;
20197         orig_conv.inner = (void*)(orig & (~1));
20198         orig_conv.is_owned = false;
20199         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
20200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20202         uint64_t ret_ref = (uint64_t)ret_var.inner;
20203         if (ret_var.is_owned) {
20204                 ret_ref |= 1;
20205         }
20206         return ret_ref;
20207 }
20208
20209 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
20210         LDKInitFeatures this_obj_conv;
20211         this_obj_conv.inner = (void*)(this_obj & (~1));
20212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20213         InitFeatures_free(this_obj_conv);
20214 }
20215
20216 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
20217         LDKNodeFeatures this_obj_conv;
20218         this_obj_conv.inner = (void*)(this_obj & (~1));
20219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20220         NodeFeatures_free(this_obj_conv);
20221 }
20222
20223 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
20224         LDKChannelFeatures this_obj_conv;
20225         this_obj_conv.inner = (void*)(this_obj & (~1));
20226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20227         ChannelFeatures_free(this_obj_conv);
20228 }
20229
20230 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
20231         LDKInvoiceFeatures this_obj_conv;
20232         this_obj_conv.inner = (void*)(this_obj & (~1));
20233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20234         InvoiceFeatures_free(this_obj_conv);
20235 }
20236
20237 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
20238         LDKInitFeatures ret_var = InitFeatures_empty();
20239         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20240         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20241         uint64_t ret_ref = (uint64_t)ret_var.inner;
20242         if (ret_var.is_owned) {
20243                 ret_ref |= 1;
20244         }
20245         return ret_ref;
20246 }
20247
20248 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
20249         LDKInitFeatures ret_var = InitFeatures_known();
20250         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20251         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20252         uint64_t ret_ref = (uint64_t)ret_var.inner;
20253         if (ret_var.is_owned) {
20254                 ret_ref |= 1;
20255         }
20256         return ret_ref;
20257 }
20258
20259 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
20260         LDKNodeFeatures ret_var = NodeFeatures_empty();
20261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20263         uint64_t ret_ref = (uint64_t)ret_var.inner;
20264         if (ret_var.is_owned) {
20265                 ret_ref |= 1;
20266         }
20267         return ret_ref;
20268 }
20269
20270 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
20271         LDKNodeFeatures ret_var = NodeFeatures_known();
20272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20274         uint64_t ret_ref = (uint64_t)ret_var.inner;
20275         if (ret_var.is_owned) {
20276                 ret_ref |= 1;
20277         }
20278         return ret_ref;
20279 }
20280
20281 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
20282         LDKChannelFeatures ret_var = ChannelFeatures_empty();
20283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20285         uint64_t ret_ref = (uint64_t)ret_var.inner;
20286         if (ret_var.is_owned) {
20287                 ret_ref |= 1;
20288         }
20289         return ret_ref;
20290 }
20291
20292 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
20293         LDKChannelFeatures ret_var = ChannelFeatures_known();
20294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20296         uint64_t ret_ref = (uint64_t)ret_var.inner;
20297         if (ret_var.is_owned) {
20298                 ret_ref |= 1;
20299         }
20300         return ret_ref;
20301 }
20302
20303 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
20304         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
20305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20307         uint64_t ret_ref = (uint64_t)ret_var.inner;
20308         if (ret_var.is_owned) {
20309                 ret_ref |= 1;
20310         }
20311         return ret_ref;
20312 }
20313
20314 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
20315         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
20316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20318         uint64_t ret_ref = (uint64_t)ret_var.inner;
20319         if (ret_var.is_owned) {
20320                 ret_ref |= 1;
20321         }
20322         return ret_ref;
20323 }
20324
20325 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
20326         LDKInitFeatures this_arg_conv;
20327         this_arg_conv.inner = (void*)(this_arg & (~1));
20328         this_arg_conv.is_owned = false;
20329         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
20330         return ret_val;
20331 }
20332
20333 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
20334         LDKNodeFeatures this_arg_conv;
20335         this_arg_conv.inner = (void*)(this_arg & (~1));
20336         this_arg_conv.is_owned = false;
20337         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
20338         return ret_val;
20339 }
20340
20341 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
20342         LDKInvoiceFeatures this_arg_conv;
20343         this_arg_conv.inner = (void*)(this_arg & (~1));
20344         this_arg_conv.is_owned = false;
20345         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
20346         return ret_val;
20347 }
20348
20349 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
20350         LDKInitFeatures obj_conv;
20351         obj_conv.inner = (void*)(obj & (~1));
20352         obj_conv.is_owned = false;
20353         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
20354         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20355         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20356         CVec_u8Z_free(ret_var);
20357         return ret_arr;
20358 }
20359
20360 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
20361         LDKNodeFeatures obj_conv;
20362         obj_conv.inner = (void*)(obj & (~1));
20363         obj_conv.is_owned = false;
20364         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
20365         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20366         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20367         CVec_u8Z_free(ret_var);
20368         return ret_arr;
20369 }
20370
20371 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
20372         LDKChannelFeatures obj_conv;
20373         obj_conv.inner = (void*)(obj & (~1));
20374         obj_conv.is_owned = false;
20375         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
20376         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20377         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20378         CVec_u8Z_free(ret_var);
20379         return ret_arr;
20380 }
20381
20382 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
20383         LDKInvoiceFeatures obj_conv;
20384         obj_conv.inner = (void*)(obj & (~1));
20385         obj_conv.is_owned = false;
20386         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
20387         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20388         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20389         CVec_u8Z_free(ret_var);
20390         return ret_arr;
20391 }
20392
20393 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
20394         LDKu8slice ser_ref;
20395         ser_ref.datalen = *((uint32_t*)ser);
20396         ser_ref.data = (int8_t*)(ser + 4);
20397         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
20398         *ret_conv = InitFeatures_read(ser_ref);
20399         return (uint64_t)ret_conv;
20400 }
20401
20402 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
20403         LDKu8slice ser_ref;
20404         ser_ref.datalen = *((uint32_t*)ser);
20405         ser_ref.data = (int8_t*)(ser + 4);
20406         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
20407         *ret_conv = NodeFeatures_read(ser_ref);
20408         return (uint64_t)ret_conv;
20409 }
20410
20411 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
20412         LDKu8slice ser_ref;
20413         ser_ref.datalen = *((uint32_t*)ser);
20414         ser_ref.data = (int8_t*)(ser + 4);
20415         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
20416         *ret_conv = ChannelFeatures_read(ser_ref);
20417         return (uint64_t)ret_conv;
20418 }
20419
20420 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
20421         LDKu8slice ser_ref;
20422         ser_ref.datalen = *((uint32_t*)ser);
20423         ser_ref.data = (int8_t*)(ser + 4);
20424         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
20425         *ret_conv = InvoiceFeatures_read(ser_ref);
20426         return (uint64_t)ret_conv;
20427 }
20428
20429 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
20430         LDKRouteHop this_obj_conv;
20431         this_obj_conv.inner = (void*)(this_obj & (~1));
20432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20433         RouteHop_free(this_obj_conv);
20434 }
20435
20436 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
20437         LDKRouteHop this_ptr_conv;
20438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20439         this_ptr_conv.is_owned = false;
20440         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20441         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
20442         return ret_arr;
20443 }
20444
20445 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
20446         LDKRouteHop this_ptr_conv;
20447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20448         this_ptr_conv.is_owned = false;
20449         LDKPublicKey val_ref;
20450         CHECK(*((uint32_t*)val) == 33);
20451         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20452         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20453 }
20454
20455 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
20456         LDKRouteHop this_ptr_conv;
20457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20458         this_ptr_conv.is_owned = false;
20459         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20462         uint64_t ret_ref = (uint64_t)ret_var.inner;
20463         if (ret_var.is_owned) {
20464                 ret_ref |= 1;
20465         }
20466         return ret_ref;
20467 }
20468
20469 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
20470         LDKRouteHop this_ptr_conv;
20471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20472         this_ptr_conv.is_owned = false;
20473         LDKNodeFeatures val_conv;
20474         val_conv.inner = (void*)(val & (~1));
20475         val_conv.is_owned = (val & 1) || (val == 0);
20476         val_conv = NodeFeatures_clone(&val_conv);
20477         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20478 }
20479
20480 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
20481         LDKRouteHop this_ptr_conv;
20482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20483         this_ptr_conv.is_owned = false;
20484         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20485         return ret_val;
20486 }
20487
20488 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20489         LDKRouteHop this_ptr_conv;
20490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20491         this_ptr_conv.is_owned = false;
20492         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20493 }
20494
20495 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
20496         LDKRouteHop this_ptr_conv;
20497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20498         this_ptr_conv.is_owned = false;
20499         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20502         uint64_t ret_ref = (uint64_t)ret_var.inner;
20503         if (ret_var.is_owned) {
20504                 ret_ref |= 1;
20505         }
20506         return ret_ref;
20507 }
20508
20509 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
20510         LDKRouteHop this_ptr_conv;
20511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20512         this_ptr_conv.is_owned = false;
20513         LDKChannelFeatures val_conv;
20514         val_conv.inner = (void*)(val & (~1));
20515         val_conv.is_owned = (val & 1) || (val == 0);
20516         val_conv = ChannelFeatures_clone(&val_conv);
20517         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20518 }
20519
20520 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
20521         LDKRouteHop this_ptr_conv;
20522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20523         this_ptr_conv.is_owned = false;
20524         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20525         return ret_val;
20526 }
20527
20528 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
20529         LDKRouteHop this_ptr_conv;
20530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20531         this_ptr_conv.is_owned = false;
20532         RouteHop_set_fee_msat(&this_ptr_conv, val);
20533 }
20534
20535 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20536         LDKRouteHop this_ptr_conv;
20537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20538         this_ptr_conv.is_owned = false;
20539         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20540         return ret_val;
20541 }
20542
20543 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
20544         LDKRouteHop this_ptr_conv;
20545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20546         this_ptr_conv.is_owned = false;
20547         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20548 }
20549
20550 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) {
20551         LDKPublicKey pubkey_arg_ref;
20552         CHECK(*((uint32_t*)pubkey_arg) == 33);
20553         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
20554         LDKNodeFeatures node_features_arg_conv;
20555         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20556         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20557         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20558         LDKChannelFeatures channel_features_arg_conv;
20559         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20560         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20561         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20562         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);
20563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20565         uint64_t ret_ref = (uint64_t)ret_var.inner;
20566         if (ret_var.is_owned) {
20567                 ret_ref |= 1;
20568         }
20569         return ret_ref;
20570 }
20571
20572 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
20573         LDKRouteHop orig_conv;
20574         orig_conv.inner = (void*)(orig & (~1));
20575         orig_conv.is_owned = false;
20576         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20579         uint64_t ret_ref = (uint64_t)ret_var.inner;
20580         if (ret_var.is_owned) {
20581                 ret_ref |= 1;
20582         }
20583         return ret_ref;
20584 }
20585
20586 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
20587         LDKRouteHop obj_conv;
20588         obj_conv.inner = (void*)(obj & (~1));
20589         obj_conv.is_owned = false;
20590         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
20591         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20592         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20593         CVec_u8Z_free(ret_var);
20594         return ret_arr;
20595 }
20596
20597 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
20598         LDKu8slice ser_ref;
20599         ser_ref.datalen = *((uint32_t*)ser);
20600         ser_ref.data = (int8_t*)(ser + 4);
20601         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
20602         *ret_conv = RouteHop_read(ser_ref);
20603         return (uint64_t)ret_conv;
20604 }
20605
20606 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
20607         LDKRoute this_obj_conv;
20608         this_obj_conv.inner = (void*)(this_obj & (~1));
20609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20610         Route_free(this_obj_conv);
20611 }
20612
20613 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
20614         LDKRoute this_ptr_conv;
20615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20616         this_ptr_conv.is_owned = false;
20617         LDKCVec_CVec_RouteHopZZ val_constr;
20618         val_constr.datalen = *((uint32_t*)val);
20619         if (val_constr.datalen > 0)
20620                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20621         else
20622                 val_constr.data = NULL;
20623         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
20624         for (size_t m = 0; m < val_constr.datalen; m++) {
20625                 uint32_tArray val_conv_12 = val_vals[m];
20626                 LDKCVec_RouteHopZ val_conv_12_constr;
20627                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
20628                 if (val_conv_12_constr.datalen > 0)
20629                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20630                 else
20631                         val_conv_12_constr.data = NULL;
20632                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
20633                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20634                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
20635                         LDKRouteHop val_conv_12_conv_10_conv;
20636                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20637                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20638                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20639                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20640                 }
20641                 val_constr.data[m] = val_conv_12_constr;
20642         }
20643         Route_set_paths(&this_ptr_conv, val_constr);
20644 }
20645
20646 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
20647         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20648         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
20649         if (paths_arg_constr.datalen > 0)
20650                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20651         else
20652                 paths_arg_constr.data = NULL;
20653         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
20654         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20655                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
20656                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20657                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
20658                 if (paths_arg_conv_12_constr.datalen > 0)
20659                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20660                 else
20661                         paths_arg_conv_12_constr.data = NULL;
20662                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
20663                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20664                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20665                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20666                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20667                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20668                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20669                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20670                 }
20671                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20672         }
20673         LDKRoute ret_var = Route_new(paths_arg_constr);
20674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20676         uint64_t ret_ref = (uint64_t)ret_var.inner;
20677         if (ret_var.is_owned) {
20678                 ret_ref |= 1;
20679         }
20680         return ret_ref;
20681 }
20682
20683 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
20684         LDKRoute orig_conv;
20685         orig_conv.inner = (void*)(orig & (~1));
20686         orig_conv.is_owned = false;
20687         LDKRoute ret_var = Route_clone(&orig_conv);
20688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20690         uint64_t ret_ref = (uint64_t)ret_var.inner;
20691         if (ret_var.is_owned) {
20692                 ret_ref |= 1;
20693         }
20694         return ret_ref;
20695 }
20696
20697 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
20698         LDKRoute obj_conv;
20699         obj_conv.inner = (void*)(obj & (~1));
20700         obj_conv.is_owned = false;
20701         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20702         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20703         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20704         CVec_u8Z_free(ret_var);
20705         return ret_arr;
20706 }
20707
20708 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
20709         LDKu8slice ser_ref;
20710         ser_ref.datalen = *((uint32_t*)ser);
20711         ser_ref.data = (int8_t*)(ser + 4);
20712         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20713         *ret_conv = Route_read(ser_ref);
20714         return (uint64_t)ret_conv;
20715 }
20716
20717 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
20718         LDKRouteHint this_obj_conv;
20719         this_obj_conv.inner = (void*)(this_obj & (~1));
20720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20721         RouteHint_free(this_obj_conv);
20722 }
20723
20724 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
20725         LDKRouteHint a_conv;
20726         a_conv.inner = (void*)(a & (~1));
20727         a_conv.is_owned = false;
20728         LDKRouteHint b_conv;
20729         b_conv.inner = (void*)(b & (~1));
20730         b_conv.is_owned = false;
20731         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
20732         return ret_val;
20733 }
20734
20735 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
20736         LDKRouteHint orig_conv;
20737         orig_conv.inner = (void*)(orig & (~1));
20738         orig_conv.is_owned = false;
20739         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20742         uint64_t ret_ref = (uint64_t)ret_var.inner;
20743         if (ret_var.is_owned) {
20744                 ret_ref |= 1;
20745         }
20746         return ret_ref;
20747 }
20748
20749 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
20750         LDKRouteHintHop this_obj_conv;
20751         this_obj_conv.inner = (void*)(this_obj & (~1));
20752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20753         RouteHintHop_free(this_obj_conv);
20754 }
20755
20756 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
20757         LDKRouteHintHop this_ptr_conv;
20758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20759         this_ptr_conv.is_owned = false;
20760         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20761         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
20762         return ret_arr;
20763 }
20764
20765 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
20766         LDKRouteHintHop this_ptr_conv;
20767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20768         this_ptr_conv.is_owned = false;
20769         LDKPublicKey val_ref;
20770         CHECK(*((uint32_t*)val) == 33);
20771         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20772         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
20773 }
20774
20775 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
20776         LDKRouteHintHop this_ptr_conv;
20777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20778         this_ptr_conv.is_owned = false;
20779         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
20780         return ret_val;
20781 }
20782
20783 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20784         LDKRouteHintHop this_ptr_conv;
20785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20786         this_ptr_conv.is_owned = false;
20787         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
20788 }
20789
20790 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
20791         LDKRouteHintHop this_ptr_conv;
20792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20793         this_ptr_conv.is_owned = false;
20794         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
20795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20797         uint64_t ret_ref = (uint64_t)ret_var.inner;
20798         if (ret_var.is_owned) {
20799                 ret_ref |= 1;
20800         }
20801         return ret_ref;
20802 }
20803
20804 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
20805         LDKRouteHintHop this_ptr_conv;
20806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20807         this_ptr_conv.is_owned = false;
20808         LDKRoutingFees val_conv;
20809         val_conv.inner = (void*)(val & (~1));
20810         val_conv.is_owned = (val & 1) || (val == 0);
20811         val_conv = RoutingFees_clone(&val_conv);
20812         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
20813 }
20814
20815 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20816         LDKRouteHintHop this_ptr_conv;
20817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20818         this_ptr_conv.is_owned = false;
20819         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
20820         return ret_val;
20821 }
20822
20823 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20824         LDKRouteHintHop this_ptr_conv;
20825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20826         this_ptr_conv.is_owned = false;
20827         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20828 }
20829
20830 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
20831         LDKRouteHintHop this_ptr_conv;
20832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20833         this_ptr_conv.is_owned = false;
20834         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20835         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
20836         uint64_t ret_ref = (uint64_t)ret_copy;
20837         return ret_ref;
20838 }
20839
20840 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
20841         LDKRouteHintHop this_ptr_conv;
20842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20843         this_ptr_conv.is_owned = false;
20844         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20845         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20846 }
20847
20848 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
20849         LDKRouteHintHop this_ptr_conv;
20850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20851         this_ptr_conv.is_owned = false;
20852         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20853         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
20854         uint64_t ret_ref = (uint64_t)ret_copy;
20855         return ret_ref;
20856 }
20857
20858 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20859         LDKRouteHintHop this_ptr_conv;
20860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20861         this_ptr_conv.is_owned = false;
20862         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20863         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20864 }
20865
20866 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_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) {
20867         LDKPublicKey src_node_id_arg_ref;
20868         CHECK(*((uint32_t*)src_node_id_arg) == 33);
20869         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
20870         LDKRoutingFees fees_arg_conv;
20871         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20872         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20873         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20874         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20875         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20876         LDKRouteHintHop ret_var = RouteHintHop_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);
20877         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20878         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20879         uint64_t ret_ref = (uint64_t)ret_var.inner;
20880         if (ret_var.is_owned) {
20881                 ret_ref |= 1;
20882         }
20883         return ret_ref;
20884 }
20885
20886 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
20887         LDKRouteHintHop a_conv;
20888         a_conv.inner = (void*)(a & (~1));
20889         a_conv.is_owned = false;
20890         LDKRouteHintHop b_conv;
20891         b_conv.inner = (void*)(b & (~1));
20892         b_conv.is_owned = false;
20893         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
20894         return ret_val;
20895 }
20896
20897 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
20898         LDKRouteHintHop orig_conv;
20899         orig_conv.inner = (void*)(orig & (~1));
20900         orig_conv.is_owned = false;
20901         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
20902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20904         uint64_t ret_ref = (uint64_t)ret_var.inner;
20905         if (ret_var.is_owned) {
20906                 ret_ref |= 1;
20907         }
20908         return ret_ref;
20909 }
20910
20911 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) {
20912         LDKPublicKey our_node_id_ref;
20913         CHECK(*((uint32_t*)our_node_id) == 33);
20914         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
20915         LDKNetworkGraph network_conv;
20916         network_conv.inner = (void*)(network & (~1));
20917         network_conv.is_owned = false;
20918         LDKPublicKey payee_ref;
20919         CHECK(*((uint32_t*)payee) == 33);
20920         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
20921         LDKInvoiceFeatures payee_features_conv;
20922         payee_features_conv.inner = (void*)(payee_features & (~1));
20923         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20924         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20925         LDKCVec_ChannelDetailsZ first_hops_constr;
20926         first_hops_constr.datalen = *((uint32_t*)first_hops);
20927         if (first_hops_constr.datalen > 0)
20928                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20929         else
20930                 first_hops_constr.data = NULL;
20931         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
20932         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20933                 uint32_t first_hops_conv_16 = first_hops_vals[q];
20934                 LDKChannelDetails first_hops_conv_16_conv;
20935                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20936                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20937                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20938         }
20939         LDKCVec_RouteHintZ last_hops_constr;
20940         last_hops_constr.datalen = *((uint32_t*)last_hops);
20941         if (last_hops_constr.datalen > 0)
20942                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20943         else
20944                 last_hops_constr.data = NULL;
20945         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
20946         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20947                 uint32_t last_hops_conv_11 = last_hops_vals[l];
20948                 LDKRouteHint last_hops_conv_11_conv;
20949                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20950                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20951                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20952                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20953         }
20954         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20955         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20956         *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);
20957         FREE(first_hops_constr.data);
20958         return (uint64_t)ret_conv;
20959 }
20960
20961 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
20962         LDKNetworkGraph this_obj_conv;
20963         this_obj_conv.inner = (void*)(this_obj & (~1));
20964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20965         NetworkGraph_free(this_obj_conv);
20966 }
20967
20968 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
20969         LDKNetworkGraph orig_conv;
20970         orig_conv.inner = (void*)(orig & (~1));
20971         orig_conv.is_owned = false;
20972         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20973         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20974         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20975         uint64_t ret_ref = (uint64_t)ret_var.inner;
20976         if (ret_var.is_owned) {
20977                 ret_ref |= 1;
20978         }
20979         return ret_ref;
20980 }
20981
20982 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
20983         LDKLockedNetworkGraph this_obj_conv;
20984         this_obj_conv.inner = (void*)(this_obj & (~1));
20985         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20986         LockedNetworkGraph_free(this_obj_conv);
20987 }
20988
20989 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
20990         LDKNetGraphMsgHandler this_obj_conv;
20991         this_obj_conv.inner = (void*)(this_obj & (~1));
20992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20993         NetGraphMsgHandler_free(this_obj_conv);
20994 }
20995
20996 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
20997         LDKThirtyTwoBytes genesis_hash_ref;
20998         CHECK(*((uint32_t*)genesis_hash) == 32);
20999         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21000         LDKAccess *chain_access_conv_ptr = NULL;
21001         if (chain_access != 0) {
21002                 LDKAccess chain_access_conv;
21003                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21004                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21005                 *chain_access_conv_ptr = chain_access_conv;
21006         }
21007         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21008         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
21009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21011         uint64_t ret_ref = (uint64_t)ret_var.inner;
21012         if (ret_var.is_owned) {
21013                 ret_ref |= 1;
21014         }
21015         return ret_ref;
21016 }
21017
21018 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
21019         LDKAccess *chain_access_conv_ptr = NULL;
21020         if (chain_access != 0) {
21021                 LDKAccess chain_access_conv;
21022                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21023                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21024                 *chain_access_conv_ptr = chain_access_conv;
21025         }
21026         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21027         LDKNetworkGraph network_graph_conv;
21028         network_graph_conv.inner = (void*)(network_graph & (~1));
21029         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
21030         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
21031         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
21032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21034         uint64_t ret_ref = (uint64_t)ret_var.inner;
21035         if (ret_var.is_owned) {
21036                 ret_ref |= 1;
21037         }
21038         return ret_ref;
21039 }
21040
21041 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
21042         LDKNetGraphMsgHandler this_arg_conv;
21043         this_arg_conv.inner = (void*)(this_arg & (~1));
21044         this_arg_conv.is_owned = false;
21045         LDKAccess *chain_access_conv_ptr = NULL;
21046         if (chain_access != 0) {
21047                 LDKAccess chain_access_conv;
21048                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21049                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21050                 *chain_access_conv_ptr = chain_access_conv;
21051         }
21052         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
21053 }
21054
21055 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
21056         LDKNetGraphMsgHandler this_arg_conv;
21057         this_arg_conv.inner = (void*)(this_arg & (~1));
21058         this_arg_conv.is_owned = false;
21059         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
21060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21062         uint64_t ret_ref = (uint64_t)ret_var.inner;
21063         if (ret_var.is_owned) {
21064                 ret_ref |= 1;
21065         }
21066         return ret_ref;
21067 }
21068
21069 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
21070         LDKLockedNetworkGraph this_arg_conv;
21071         this_arg_conv.inner = (void*)(this_arg & (~1));
21072         this_arg_conv.is_owned = false;
21073         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
21074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21076         uint64_t ret_ref = (uint64_t)ret_var.inner;
21077         if (ret_var.is_owned) {
21078                 ret_ref |= 1;
21079         }
21080         return ret_ref;
21081 }
21082
21083 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
21084         LDKNetGraphMsgHandler this_arg_conv;
21085         this_arg_conv.inner = (void*)(this_arg & (~1));
21086         this_arg_conv.is_owned = false;
21087         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21088         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
21089         return (uint64_t)ret;
21090 }
21091
21092 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
21093         LDKNetGraphMsgHandler this_arg_conv;
21094         this_arg_conv.inner = (void*)(this_arg & (~1));
21095         this_arg_conv.is_owned = false;
21096         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21097         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
21098         return (uint64_t)ret;
21099 }
21100
21101 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
21102         LDKDirectionalChannelInfo this_obj_conv;
21103         this_obj_conv.inner = (void*)(this_obj & (~1));
21104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21105         DirectionalChannelInfo_free(this_obj_conv);
21106 }
21107
21108 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
21109         LDKDirectionalChannelInfo this_ptr_conv;
21110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21111         this_ptr_conv.is_owned = false;
21112         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
21113         return ret_val;
21114 }
21115
21116 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21117         LDKDirectionalChannelInfo this_ptr_conv;
21118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21119         this_ptr_conv.is_owned = false;
21120         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
21121 }
21122
21123 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
21124         LDKDirectionalChannelInfo this_ptr_conv;
21125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21126         this_ptr_conv.is_owned = false;
21127         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
21128         return ret_val;
21129 }
21130
21131 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
21132         LDKDirectionalChannelInfo this_ptr_conv;
21133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21134         this_ptr_conv.is_owned = false;
21135         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
21136 }
21137
21138 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
21139         LDKDirectionalChannelInfo this_ptr_conv;
21140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21141         this_ptr_conv.is_owned = false;
21142         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
21143         return ret_val;
21144 }
21145
21146 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21147         LDKDirectionalChannelInfo this_ptr_conv;
21148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21149         this_ptr_conv.is_owned = false;
21150         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
21151 }
21152
21153 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
21154         LDKDirectionalChannelInfo this_ptr_conv;
21155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21156         this_ptr_conv.is_owned = false;
21157         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
21158         return ret_val;
21159 }
21160
21161 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
21162         LDKDirectionalChannelInfo this_ptr_conv;
21163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21164         this_ptr_conv.is_owned = false;
21165         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
21166 }
21167
21168 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
21169         LDKDirectionalChannelInfo this_ptr_conv;
21170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21171         this_ptr_conv.is_owned = false;
21172         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21173         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
21174         uint64_t ret_ref = (uint64_t)ret_copy;
21175         return ret_ref;
21176 }
21177
21178 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
21179         LDKDirectionalChannelInfo this_ptr_conv;
21180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21181         this_ptr_conv.is_owned = false;
21182         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21183         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
21184 }
21185
21186 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
21187         LDKDirectionalChannelInfo this_ptr_conv;
21188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21189         this_ptr_conv.is_owned = false;
21190         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
21191         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21192         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21193         uint64_t ret_ref = (uint64_t)ret_var.inner;
21194         if (ret_var.is_owned) {
21195                 ret_ref |= 1;
21196         }
21197         return ret_ref;
21198 }
21199
21200 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
21201         LDKDirectionalChannelInfo this_ptr_conv;
21202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21203         this_ptr_conv.is_owned = false;
21204         LDKRoutingFees val_conv;
21205         val_conv.inner = (void*)(val & (~1));
21206         val_conv.is_owned = (val & 1) || (val == 0);
21207         val_conv = RoutingFees_clone(&val_conv);
21208         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
21209 }
21210
21211 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
21212         LDKDirectionalChannelInfo this_ptr_conv;
21213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21214         this_ptr_conv.is_owned = false;
21215         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
21216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21218         uint64_t ret_ref = (uint64_t)ret_var.inner;
21219         if (ret_var.is_owned) {
21220                 ret_ref |= 1;
21221         }
21222         return ret_ref;
21223 }
21224
21225 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
21226         LDKDirectionalChannelInfo this_ptr_conv;
21227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21228         this_ptr_conv.is_owned = false;
21229         LDKChannelUpdate val_conv;
21230         val_conv.inner = (void*)(val & (~1));
21231         val_conv.is_owned = (val & 1) || (val == 0);
21232         val_conv = ChannelUpdate_clone(&val_conv);
21233         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
21234 }
21235
21236 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) {
21237         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
21238         LDKRoutingFees fees_arg_conv;
21239         fees_arg_conv.inner = (void*)(fees_arg & (~1));
21240         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
21241         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
21242         LDKChannelUpdate last_update_message_arg_conv;
21243         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
21244         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
21245         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
21246         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);
21247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21249         uint64_t ret_ref = (uint64_t)ret_var.inner;
21250         if (ret_var.is_owned) {
21251                 ret_ref |= 1;
21252         }
21253         return ret_ref;
21254 }
21255
21256 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
21257         LDKDirectionalChannelInfo orig_conv;
21258         orig_conv.inner = (void*)(orig & (~1));
21259         orig_conv.is_owned = false;
21260         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
21261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21263         uint64_t ret_ref = (uint64_t)ret_var.inner;
21264         if (ret_var.is_owned) {
21265                 ret_ref |= 1;
21266         }
21267         return ret_ref;
21268 }
21269
21270 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
21271         LDKDirectionalChannelInfo obj_conv;
21272         obj_conv.inner = (void*)(obj & (~1));
21273         obj_conv.is_owned = false;
21274         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
21275         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21276         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21277         CVec_u8Z_free(ret_var);
21278         return ret_arr;
21279 }
21280
21281 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
21282         LDKu8slice ser_ref;
21283         ser_ref.datalen = *((uint32_t*)ser);
21284         ser_ref.data = (int8_t*)(ser + 4);
21285         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
21286         *ret_conv = DirectionalChannelInfo_read(ser_ref);
21287         return (uint64_t)ret_conv;
21288 }
21289
21290 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
21291         LDKChannelInfo this_obj_conv;
21292         this_obj_conv.inner = (void*)(this_obj & (~1));
21293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21294         ChannelInfo_free(this_obj_conv);
21295 }
21296
21297 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
21298         LDKChannelInfo this_ptr_conv;
21299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21300         this_ptr_conv.is_owned = false;
21301         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
21302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21304         uint64_t ret_ref = (uint64_t)ret_var.inner;
21305         if (ret_var.is_owned) {
21306                 ret_ref |= 1;
21307         }
21308         return ret_ref;
21309 }
21310
21311 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
21312         LDKChannelInfo this_ptr_conv;
21313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21314         this_ptr_conv.is_owned = false;
21315         LDKChannelFeatures val_conv;
21316         val_conv.inner = (void*)(val & (~1));
21317         val_conv.is_owned = (val & 1) || (val == 0);
21318         val_conv = ChannelFeatures_clone(&val_conv);
21319         ChannelInfo_set_features(&this_ptr_conv, val_conv);
21320 }
21321
21322 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
21323         LDKChannelInfo this_ptr_conv;
21324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21325         this_ptr_conv.is_owned = false;
21326         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21327         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
21328         return ret_arr;
21329 }
21330
21331 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
21332         LDKChannelInfo this_ptr_conv;
21333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21334         this_ptr_conv.is_owned = false;
21335         LDKPublicKey val_ref;
21336         CHECK(*((uint32_t*)val) == 33);
21337         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21338         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
21339 }
21340
21341 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
21342         LDKChannelInfo this_ptr_conv;
21343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21344         this_ptr_conv.is_owned = false;
21345         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
21346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21348         uint64_t ret_ref = (uint64_t)ret_var.inner;
21349         if (ret_var.is_owned) {
21350                 ret_ref |= 1;
21351         }
21352         return ret_ref;
21353 }
21354
21355 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
21356         LDKChannelInfo this_ptr_conv;
21357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21358         this_ptr_conv.is_owned = false;
21359         LDKDirectionalChannelInfo val_conv;
21360         val_conv.inner = (void*)(val & (~1));
21361         val_conv.is_owned = (val & 1) || (val == 0);
21362         val_conv = DirectionalChannelInfo_clone(&val_conv);
21363         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
21364 }
21365
21366 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
21367         LDKChannelInfo this_ptr_conv;
21368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21369         this_ptr_conv.is_owned = false;
21370         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21371         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
21372         return ret_arr;
21373 }
21374
21375 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
21376         LDKChannelInfo this_ptr_conv;
21377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21378         this_ptr_conv.is_owned = false;
21379         LDKPublicKey val_ref;
21380         CHECK(*((uint32_t*)val) == 33);
21381         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21382         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
21383 }
21384
21385 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
21386         LDKChannelInfo this_ptr_conv;
21387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21388         this_ptr_conv.is_owned = false;
21389         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
21390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21392         uint64_t ret_ref = (uint64_t)ret_var.inner;
21393         if (ret_var.is_owned) {
21394                 ret_ref |= 1;
21395         }
21396         return ret_ref;
21397 }
21398
21399 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
21400         LDKChannelInfo this_ptr_conv;
21401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21402         this_ptr_conv.is_owned = false;
21403         LDKDirectionalChannelInfo val_conv;
21404         val_conv.inner = (void*)(val & (~1));
21405         val_conv.is_owned = (val & 1) || (val == 0);
21406         val_conv = DirectionalChannelInfo_clone(&val_conv);
21407         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
21408 }
21409
21410 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
21411         LDKChannelInfo this_ptr_conv;
21412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21413         this_ptr_conv.is_owned = false;
21414         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21415         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
21416         uint64_t ret_ref = (uint64_t)ret_copy;
21417         return ret_ref;
21418 }
21419
21420 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
21421         LDKChannelInfo this_ptr_conv;
21422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21423         this_ptr_conv.is_owned = false;
21424         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21425         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
21426 }
21427
21428 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
21429         LDKChannelInfo this_ptr_conv;
21430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21431         this_ptr_conv.is_owned = false;
21432         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
21433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21435         uint64_t ret_ref = (uint64_t)ret_var.inner;
21436         if (ret_var.is_owned) {
21437                 ret_ref |= 1;
21438         }
21439         return ret_ref;
21440 }
21441
21442 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21443         LDKChannelInfo this_ptr_conv;
21444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21445         this_ptr_conv.is_owned = false;
21446         LDKChannelAnnouncement val_conv;
21447         val_conv.inner = (void*)(val & (~1));
21448         val_conv.is_owned = (val & 1) || (val == 0);
21449         val_conv = ChannelAnnouncement_clone(&val_conv);
21450         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
21451 }
21452
21453 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) {
21454         LDKChannelFeatures features_arg_conv;
21455         features_arg_conv.inner = (void*)(features_arg & (~1));
21456         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21457         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
21458         LDKPublicKey node_one_arg_ref;
21459         CHECK(*((uint32_t*)node_one_arg) == 33);
21460         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
21461         LDKDirectionalChannelInfo one_to_two_arg_conv;
21462         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
21463         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
21464         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
21465         LDKPublicKey node_two_arg_ref;
21466         CHECK(*((uint32_t*)node_two_arg) == 33);
21467         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
21468         LDKDirectionalChannelInfo two_to_one_arg_conv;
21469         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
21470         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
21471         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
21472         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
21473         LDKChannelAnnouncement announcement_message_arg_conv;
21474         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21475         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21476         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21477         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);
21478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21480         uint64_t ret_ref = (uint64_t)ret_var.inner;
21481         if (ret_var.is_owned) {
21482                 ret_ref |= 1;
21483         }
21484         return ret_ref;
21485 }
21486
21487 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
21488         LDKChannelInfo orig_conv;
21489         orig_conv.inner = (void*)(orig & (~1));
21490         orig_conv.is_owned = false;
21491         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21492         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21493         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21494         uint64_t ret_ref = (uint64_t)ret_var.inner;
21495         if (ret_var.is_owned) {
21496                 ret_ref |= 1;
21497         }
21498         return ret_ref;
21499 }
21500
21501 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
21502         LDKChannelInfo obj_conv;
21503         obj_conv.inner = (void*)(obj & (~1));
21504         obj_conv.is_owned = false;
21505         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21506         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21507         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21508         CVec_u8Z_free(ret_var);
21509         return ret_arr;
21510 }
21511
21512 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
21513         LDKu8slice ser_ref;
21514         ser_ref.datalen = *((uint32_t*)ser);
21515         ser_ref.data = (int8_t*)(ser + 4);
21516         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21517         *ret_conv = ChannelInfo_read(ser_ref);
21518         return (uint64_t)ret_conv;
21519 }
21520
21521 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
21522         LDKRoutingFees this_obj_conv;
21523         this_obj_conv.inner = (void*)(this_obj & (~1));
21524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21525         RoutingFees_free(this_obj_conv);
21526 }
21527
21528 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
21529         LDKRoutingFees this_ptr_conv;
21530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21531         this_ptr_conv.is_owned = false;
21532         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21533         return ret_val;
21534 }
21535
21536 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
21537         LDKRoutingFees this_ptr_conv;
21538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21539         this_ptr_conv.is_owned = false;
21540         RoutingFees_set_base_msat(&this_ptr_conv, val);
21541 }
21542
21543 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
21544         LDKRoutingFees this_ptr_conv;
21545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21546         this_ptr_conv.is_owned = false;
21547         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21548         return ret_val;
21549 }
21550
21551 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
21552         LDKRoutingFees this_ptr_conv;
21553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21554         this_ptr_conv.is_owned = false;
21555         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21556 }
21557
21558 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
21559         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21560         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21561         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21562         uint64_t ret_ref = (uint64_t)ret_var.inner;
21563         if (ret_var.is_owned) {
21564                 ret_ref |= 1;
21565         }
21566         return ret_ref;
21567 }
21568
21569 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
21570         LDKRoutingFees a_conv;
21571         a_conv.inner = (void*)(a & (~1));
21572         a_conv.is_owned = false;
21573         LDKRoutingFees b_conv;
21574         b_conv.inner = (void*)(b & (~1));
21575         b_conv.is_owned = false;
21576         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
21577         return ret_val;
21578 }
21579
21580 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
21581         LDKRoutingFees orig_conv;
21582         orig_conv.inner = (void*)(orig & (~1));
21583         orig_conv.is_owned = false;
21584         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21587         uint64_t ret_ref = (uint64_t)ret_var.inner;
21588         if (ret_var.is_owned) {
21589                 ret_ref |= 1;
21590         }
21591         return ret_ref;
21592 }
21593
21594 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
21595         LDKRoutingFees obj_conv;
21596         obj_conv.inner = (void*)(obj & (~1));
21597         obj_conv.is_owned = false;
21598         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21599         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21600         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21601         CVec_u8Z_free(ret_var);
21602         return ret_arr;
21603 }
21604
21605 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
21606         LDKu8slice ser_ref;
21607         ser_ref.datalen = *((uint32_t*)ser);
21608         ser_ref.data = (int8_t*)(ser + 4);
21609         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21610         *ret_conv = RoutingFees_read(ser_ref);
21611         return (uint64_t)ret_conv;
21612 }
21613
21614 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
21615         LDKNodeAnnouncementInfo this_obj_conv;
21616         this_obj_conv.inner = (void*)(this_obj & (~1));
21617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21618         NodeAnnouncementInfo_free(this_obj_conv);
21619 }
21620
21621 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
21622         LDKNodeAnnouncementInfo this_ptr_conv;
21623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21624         this_ptr_conv.is_owned = false;
21625         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21628         uint64_t ret_ref = (uint64_t)ret_var.inner;
21629         if (ret_var.is_owned) {
21630                 ret_ref |= 1;
21631         }
21632         return ret_ref;
21633 }
21634
21635 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
21636         LDKNodeAnnouncementInfo this_ptr_conv;
21637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21638         this_ptr_conv.is_owned = false;
21639         LDKNodeFeatures val_conv;
21640         val_conv.inner = (void*)(val & (~1));
21641         val_conv.is_owned = (val & 1) || (val == 0);
21642         val_conv = NodeFeatures_clone(&val_conv);
21643         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21644 }
21645
21646 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
21647         LDKNodeAnnouncementInfo this_ptr_conv;
21648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21649         this_ptr_conv.is_owned = false;
21650         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21651         return ret_val;
21652 }
21653
21654 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21655         LDKNodeAnnouncementInfo this_ptr_conv;
21656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21657         this_ptr_conv.is_owned = false;
21658         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21659 }
21660
21661 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
21662         LDKNodeAnnouncementInfo this_ptr_conv;
21663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21664         this_ptr_conv.is_owned = false;
21665         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
21666         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
21667         return ret_arr;
21668 }
21669
21670 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
21671         LDKNodeAnnouncementInfo this_ptr_conv;
21672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21673         this_ptr_conv.is_owned = false;
21674         LDKThreeBytes val_ref;
21675         CHECK(*((uint32_t*)val) == 3);
21676         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
21677         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21678 }
21679
21680 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
21681         LDKNodeAnnouncementInfo this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21685         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
21686         return ret_arr;
21687 }
21688
21689 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
21690         LDKNodeAnnouncementInfo this_ptr_conv;
21691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21692         this_ptr_conv.is_owned = false;
21693         LDKThirtyTwoBytes val_ref;
21694         CHECK(*((uint32_t*)val) == 32);
21695         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21696         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21697 }
21698
21699 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
21700         LDKNodeAnnouncementInfo this_ptr_conv;
21701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21702         this_ptr_conv.is_owned = false;
21703         LDKCVec_NetAddressZ val_constr;
21704         val_constr.datalen = *((uint32_t*)val);
21705         if (val_constr.datalen > 0)
21706                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21707         else
21708                 val_constr.data = NULL;
21709         uint32_t* val_vals = (uint32_t*)(val + 4);
21710         for (size_t m = 0; m < val_constr.datalen; m++) {
21711                 uint32_t val_conv_12 = val_vals[m];
21712                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21713                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21714                 val_constr.data[m] = val_conv_12_conv;
21715         }
21716         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21717 }
21718
21719 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
21720         LDKNodeAnnouncementInfo this_ptr_conv;
21721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21722         this_ptr_conv.is_owned = false;
21723         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21726         uint64_t ret_ref = (uint64_t)ret_var.inner;
21727         if (ret_var.is_owned) {
21728                 ret_ref |= 1;
21729         }
21730         return ret_ref;
21731 }
21732
21733 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21734         LDKNodeAnnouncementInfo this_ptr_conv;
21735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21736         this_ptr_conv.is_owned = false;
21737         LDKNodeAnnouncement val_conv;
21738         val_conv.inner = (void*)(val & (~1));
21739         val_conv.is_owned = (val & 1) || (val == 0);
21740         val_conv = NodeAnnouncement_clone(&val_conv);
21741         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21742 }
21743
21744 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) {
21745         LDKNodeFeatures features_arg_conv;
21746         features_arg_conv.inner = (void*)(features_arg & (~1));
21747         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21748         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21749         LDKThreeBytes rgb_arg_ref;
21750         CHECK(*((uint32_t*)rgb_arg) == 3);
21751         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
21752         LDKThirtyTwoBytes alias_arg_ref;
21753         CHECK(*((uint32_t*)alias_arg) == 32);
21754         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
21755         LDKCVec_NetAddressZ addresses_arg_constr;
21756         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
21757         if (addresses_arg_constr.datalen > 0)
21758                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21759         else
21760                 addresses_arg_constr.data = NULL;
21761         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
21762         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21763                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
21764                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21765                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21766         }
21767         LDKNodeAnnouncement announcement_message_arg_conv;
21768         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21769         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21770         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21771         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21774         uint64_t ret_ref = (uint64_t)ret_var.inner;
21775         if (ret_var.is_owned) {
21776                 ret_ref |= 1;
21777         }
21778         return ret_ref;
21779 }
21780
21781 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
21782         LDKNodeAnnouncementInfo orig_conv;
21783         orig_conv.inner = (void*)(orig & (~1));
21784         orig_conv.is_owned = false;
21785         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21788         uint64_t ret_ref = (uint64_t)ret_var.inner;
21789         if (ret_var.is_owned) {
21790                 ret_ref |= 1;
21791         }
21792         return ret_ref;
21793 }
21794
21795 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
21796         LDKNodeAnnouncementInfo obj_conv;
21797         obj_conv.inner = (void*)(obj & (~1));
21798         obj_conv.is_owned = false;
21799         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21800         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21801         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21802         CVec_u8Z_free(ret_var);
21803         return ret_arr;
21804 }
21805
21806 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
21807         LDKu8slice ser_ref;
21808         ser_ref.datalen = *((uint32_t*)ser);
21809         ser_ref.data = (int8_t*)(ser + 4);
21810         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21811         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21812         return (uint64_t)ret_conv;
21813 }
21814
21815 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
21816         LDKNodeInfo this_obj_conv;
21817         this_obj_conv.inner = (void*)(this_obj & (~1));
21818         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21819         NodeInfo_free(this_obj_conv);
21820 }
21821
21822 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
21823         LDKNodeInfo this_ptr_conv;
21824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21825         this_ptr_conv.is_owned = false;
21826         LDKCVec_u64Z val_constr;
21827         val_constr.datalen = *((uint32_t*)val);
21828         if (val_constr.datalen > 0)
21829                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21830         else
21831                 val_constr.data = NULL;
21832         int64_t* val_vals = (int64_t*)(val + 4);
21833         for (size_t i = 0; i < val_constr.datalen; i++) {
21834                 int64_t val_conv_8 = val_vals[i];
21835                 val_constr.data[i] = val_conv_8;
21836         }
21837         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21838 }
21839
21840 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
21841         LDKNodeInfo this_ptr_conv;
21842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21843         this_ptr_conv.is_owned = false;
21844         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21845         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21846         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21847         uint64_t ret_ref = (uint64_t)ret_var.inner;
21848         if (ret_var.is_owned) {
21849                 ret_ref |= 1;
21850         }
21851         return ret_ref;
21852 }
21853
21854 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
21855         LDKNodeInfo this_ptr_conv;
21856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21857         this_ptr_conv.is_owned = false;
21858         LDKRoutingFees val_conv;
21859         val_conv.inner = (void*)(val & (~1));
21860         val_conv.is_owned = (val & 1) || (val == 0);
21861         val_conv = RoutingFees_clone(&val_conv);
21862         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21863 }
21864
21865 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
21866         LDKNodeInfo this_ptr_conv;
21867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21868         this_ptr_conv.is_owned = false;
21869         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21872         uint64_t ret_ref = (uint64_t)ret_var.inner;
21873         if (ret_var.is_owned) {
21874                 ret_ref |= 1;
21875         }
21876         return ret_ref;
21877 }
21878
21879 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
21880         LDKNodeInfo this_ptr_conv;
21881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21882         this_ptr_conv.is_owned = false;
21883         LDKNodeAnnouncementInfo val_conv;
21884         val_conv.inner = (void*)(val & (~1));
21885         val_conv.is_owned = (val & 1) || (val == 0);
21886         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21887         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21888 }
21889
21890 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
21891         LDKCVec_u64Z channels_arg_constr;
21892         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
21893         if (channels_arg_constr.datalen > 0)
21894                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21895         else
21896                 channels_arg_constr.data = NULL;
21897         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
21898         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
21899                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
21900                 channels_arg_constr.data[i] = channels_arg_conv_8;
21901         }
21902         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21903         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21904         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21905         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21906         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21907         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21908         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21909         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21910         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21913         uint64_t ret_ref = (uint64_t)ret_var.inner;
21914         if (ret_var.is_owned) {
21915                 ret_ref |= 1;
21916         }
21917         return ret_ref;
21918 }
21919
21920 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
21921         LDKNodeInfo orig_conv;
21922         orig_conv.inner = (void*)(orig & (~1));
21923         orig_conv.is_owned = false;
21924         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21927         uint64_t ret_ref = (uint64_t)ret_var.inner;
21928         if (ret_var.is_owned) {
21929                 ret_ref |= 1;
21930         }
21931         return ret_ref;
21932 }
21933
21934 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
21935         LDKNodeInfo obj_conv;
21936         obj_conv.inner = (void*)(obj & (~1));
21937         obj_conv.is_owned = false;
21938         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21939         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21940         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21941         CVec_u8Z_free(ret_var);
21942         return ret_arr;
21943 }
21944
21945 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
21946         LDKu8slice ser_ref;
21947         ser_ref.datalen = *((uint32_t*)ser);
21948         ser_ref.data = (int8_t*)(ser + 4);
21949         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21950         *ret_conv = NodeInfo_read(ser_ref);
21951         return (uint64_t)ret_conv;
21952 }
21953
21954 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
21955         LDKNetworkGraph obj_conv;
21956         obj_conv.inner = (void*)(obj & (~1));
21957         obj_conv.is_owned = false;
21958         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21959         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21960         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21961         CVec_u8Z_free(ret_var);
21962         return ret_arr;
21963 }
21964
21965 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
21966         LDKu8slice ser_ref;
21967         ser_ref.datalen = *((uint32_t*)ser);
21968         ser_ref.data = (int8_t*)(ser + 4);
21969         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21970         *ret_conv = NetworkGraph_read(ser_ref);
21971         return (uint64_t)ret_conv;
21972 }
21973
21974 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
21975         LDKThirtyTwoBytes genesis_hash_ref;
21976         CHECK(*((uint32_t*)genesis_hash) == 32);
21977         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21978         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21981         uint64_t ret_ref = (uint64_t)ret_var.inner;
21982         if (ret_var.is_owned) {
21983                 ret_ref |= 1;
21984         }
21985         return ret_ref;
21986 }
21987
21988 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
21989         LDKNetworkGraph this_arg_conv;
21990         this_arg_conv.inner = (void*)(this_arg & (~1));
21991         this_arg_conv.is_owned = false;
21992         LDKNodeAnnouncement msg_conv;
21993         msg_conv.inner = (void*)(msg & (~1));
21994         msg_conv.is_owned = false;
21995         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21996         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21997         return (uint64_t)ret_conv;
21998 }
21999
22000 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
22001         LDKNetworkGraph this_arg_conv;
22002         this_arg_conv.inner = (void*)(this_arg & (~1));
22003         this_arg_conv.is_owned = false;
22004         LDKUnsignedNodeAnnouncement msg_conv;
22005         msg_conv.inner = (void*)(msg & (~1));
22006         msg_conv.is_owned = false;
22007         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22008         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
22009         return (uint64_t)ret_conv;
22010 }
22011
22012 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
22013         LDKNetworkGraph this_arg_conv;
22014         this_arg_conv.inner = (void*)(this_arg & (~1));
22015         this_arg_conv.is_owned = false;
22016         LDKChannelAnnouncement msg_conv;
22017         msg_conv.inner = (void*)(msg & (~1));
22018         msg_conv.is_owned = false;
22019         LDKAccess *chain_access_conv_ptr = NULL;
22020         if (chain_access != 0) {
22021                 LDKAccess chain_access_conv;
22022                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22023                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22024                 *chain_access_conv_ptr = chain_access_conv;
22025         }
22026         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22027         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
22028         return (uint64_t)ret_conv;
22029 }
22030
22031 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
22032         LDKNetworkGraph this_arg_conv;
22033         this_arg_conv.inner = (void*)(this_arg & (~1));
22034         this_arg_conv.is_owned = false;
22035         LDKUnsignedChannelAnnouncement msg_conv;
22036         msg_conv.inner = (void*)(msg & (~1));
22037         msg_conv.is_owned = false;
22038         LDKAccess *chain_access_conv_ptr = NULL;
22039         if (chain_access != 0) {
22040                 LDKAccess chain_access_conv;
22041                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
22042                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
22043                 *chain_access_conv_ptr = chain_access_conv;
22044         }
22045         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22046         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
22047         return (uint64_t)ret_conv;
22048 }
22049
22050 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
22051         LDKNetworkGraph this_arg_conv;
22052         this_arg_conv.inner = (void*)(this_arg & (~1));
22053         this_arg_conv.is_owned = false;
22054         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
22055 }
22056
22057 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
22058         LDKNetworkGraph this_arg_conv;
22059         this_arg_conv.inner = (void*)(this_arg & (~1));
22060         this_arg_conv.is_owned = false;
22061         LDKChannelUpdate msg_conv;
22062         msg_conv.inner = (void*)(msg & (~1));
22063         msg_conv.is_owned = false;
22064         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22065         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
22066         return (uint64_t)ret_conv;
22067 }
22068
22069 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
22070         LDKNetworkGraph this_arg_conv;
22071         this_arg_conv.inner = (void*)(this_arg & (~1));
22072         this_arg_conv.is_owned = false;
22073         LDKUnsignedChannelUpdate msg_conv;
22074         msg_conv.inner = (void*)(msg & (~1));
22075         msg_conv.is_owned = false;
22076         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
22077         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
22078         return (uint64_t)ret_conv;
22079 }
22080
22081 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
22082         LDKFilesystemPersister this_obj_conv;
22083         this_obj_conv.inner = (void*)(this_obj & (~1));
22084         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22085         FilesystemPersister_free(this_obj_conv);
22086 }
22087
22088 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
22089         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
22090         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
22091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22093         uint64_t ret_ref = (uint64_t)ret_var.inner;
22094         if (ret_var.is_owned) {
22095                 ret_ref |= 1;
22096         }
22097         return ret_ref;
22098 }
22099
22100 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
22101         LDKFilesystemPersister this_arg_conv;
22102         this_arg_conv.inner = (void*)(this_arg & (~1));
22103         this_arg_conv.is_owned = false;
22104         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
22105         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22106         return ret_conv;
22107 }
22108
22109 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
22110         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
22111         LDKChannelManager manager_conv;
22112         manager_conv.inner = (void*)(manager & (~1));
22113         manager_conv.is_owned = false;
22114         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
22115         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
22116         return (uint64_t)ret_conv;
22117 }
22118
22119 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
22120         LDKFilesystemPersister this_arg_conv;
22121         this_arg_conv.inner = (void*)(this_arg & (~1));
22122         this_arg_conv.is_owned = false;
22123         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
22124         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
22125         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
22126         return (uint64_t)ret_conv;
22127 }
22128
22129 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
22130         LDKFilesystemPersister this_arg_conv;
22131         this_arg_conv.inner = (void*)(this_arg & (~1));
22132         this_arg_conv.is_owned = false;
22133         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
22134         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
22135         return (uint64_t)ret;
22136 }
22137
22138 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
22139         LDKBackgroundProcessor this_obj_conv;
22140         this_obj_conv.inner = (void*)(this_obj & (~1));
22141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22142         BackgroundProcessor_free(this_obj_conv);
22143 }
22144
22145 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
22146         if ((this_ptr & 1) != 0) return;
22147         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
22148         FREE((void*)this_ptr);
22149         ChannelManagerPersister_free(this_ptr_conv);
22150 }
22151
22152 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t peer_manager, uint32_t logger) {
22153         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
22154         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
22155         LDKChainMonitor chain_monitor_conv;
22156         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
22157         chain_monitor_conv.is_owned = false;
22158         LDKChannelManager channel_manager_conv;
22159         channel_manager_conv.inner = (void*)(channel_manager & (~1));
22160         channel_manager_conv.is_owned = false;
22161         LDKPeerManager peer_manager_conv;
22162         peer_manager_conv.inner = (void*)(peer_manager & (~1));
22163         peer_manager_conv.is_owned = false;
22164         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22165         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
22166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22168         uint64_t ret_ref = (uint64_t)ret_var.inner;
22169         if (ret_var.is_owned) {
22170                 ret_ref |= 1;
22171         }
22172         return ret_ref;
22173 }
22174
22175 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
22176         LDKBackgroundProcessor this_arg_conv;
22177         this_arg_conv.inner = (void*)(this_arg & (~1));
22178         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22179         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
22180         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
22181         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
22182         return (uint64_t)ret_conv;
22183 }
22184
22185 void  __attribute__((visibility("default"))) TS_check_platform() {
22186         check_platform();
22187 }
22188
22189 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
22190         LDKInvoice this_obj_conv;
22191         this_obj_conv.inner = (void*)(this_obj & (~1));
22192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22193         Invoice_free(this_obj_conv);
22194 }
22195
22196 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
22197         LDKInvoice a_conv;
22198         a_conv.inner = (void*)(a & (~1));
22199         a_conv.is_owned = false;
22200         LDKInvoice b_conv;
22201         b_conv.inner = (void*)(b & (~1));
22202         b_conv.is_owned = false;
22203         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
22204         return ret_val;
22205 }
22206
22207 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
22208         LDKInvoice orig_conv;
22209         orig_conv.inner = (void*)(orig & (~1));
22210         orig_conv.is_owned = false;
22211         LDKInvoice ret_var = Invoice_clone(&orig_conv);
22212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22214         uint64_t ret_ref = (uint64_t)ret_var.inner;
22215         if (ret_var.is_owned) {
22216                 ret_ref |= 1;
22217         }
22218         return ret_ref;
22219 }
22220
22221 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
22222         LDKSignedRawInvoice this_obj_conv;
22223         this_obj_conv.inner = (void*)(this_obj & (~1));
22224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22225         SignedRawInvoice_free(this_obj_conv);
22226 }
22227
22228 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
22229         LDKSignedRawInvoice a_conv;
22230         a_conv.inner = (void*)(a & (~1));
22231         a_conv.is_owned = false;
22232         LDKSignedRawInvoice b_conv;
22233         b_conv.inner = (void*)(b & (~1));
22234         b_conv.is_owned = false;
22235         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
22236         return ret_val;
22237 }
22238
22239 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
22240         LDKSignedRawInvoice orig_conv;
22241         orig_conv.inner = (void*)(orig & (~1));
22242         orig_conv.is_owned = false;
22243         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
22244         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22245         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22246         uint64_t ret_ref = (uint64_t)ret_var.inner;
22247         if (ret_var.is_owned) {
22248                 ret_ref |= 1;
22249         }
22250         return ret_ref;
22251 }
22252
22253 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
22254         LDKRawInvoice this_obj_conv;
22255         this_obj_conv.inner = (void*)(this_obj & (~1));
22256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22257         RawInvoice_free(this_obj_conv);
22258 }
22259
22260 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
22261         LDKRawInvoice this_ptr_conv;
22262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22263         this_ptr_conv.is_owned = false;
22264         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
22265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22267         uint64_t ret_ref = (uint64_t)ret_var.inner;
22268         if (ret_var.is_owned) {
22269                 ret_ref |= 1;
22270         }
22271         return ret_ref;
22272 }
22273
22274 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
22275         LDKRawInvoice this_ptr_conv;
22276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22277         this_ptr_conv.is_owned = false;
22278         LDKRawDataPart val_conv;
22279         val_conv.inner = (void*)(val & (~1));
22280         val_conv.is_owned = (val & 1) || (val == 0);
22281         val_conv = RawDataPart_clone(&val_conv);
22282         RawInvoice_set_data(&this_ptr_conv, val_conv);
22283 }
22284
22285 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
22286         LDKRawInvoice a_conv;
22287         a_conv.inner = (void*)(a & (~1));
22288         a_conv.is_owned = false;
22289         LDKRawInvoice b_conv;
22290         b_conv.inner = (void*)(b & (~1));
22291         b_conv.is_owned = false;
22292         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
22293         return ret_val;
22294 }
22295
22296 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
22297         LDKRawInvoice orig_conv;
22298         orig_conv.inner = (void*)(orig & (~1));
22299         orig_conv.is_owned = false;
22300         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
22301         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22302         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22303         uint64_t ret_ref = (uint64_t)ret_var.inner;
22304         if (ret_var.is_owned) {
22305                 ret_ref |= 1;
22306         }
22307         return ret_ref;
22308 }
22309
22310 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
22311         LDKRawDataPart this_obj_conv;
22312         this_obj_conv.inner = (void*)(this_obj & (~1));
22313         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22314         RawDataPart_free(this_obj_conv);
22315 }
22316
22317 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
22318         LDKRawDataPart this_ptr_conv;
22319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22320         this_ptr_conv.is_owned = false;
22321         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
22322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22324         uint64_t ret_ref = (uint64_t)ret_var.inner;
22325         if (ret_var.is_owned) {
22326                 ret_ref |= 1;
22327         }
22328         return ret_ref;
22329 }
22330
22331 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
22332         LDKRawDataPart this_ptr_conv;
22333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22334         this_ptr_conv.is_owned = false;
22335         LDKPositiveTimestamp val_conv;
22336         val_conv.inner = (void*)(val & (~1));
22337         val_conv.is_owned = (val & 1) || (val == 0);
22338         val_conv = PositiveTimestamp_clone(&val_conv);
22339         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
22340 }
22341
22342 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
22343         LDKRawDataPart a_conv;
22344         a_conv.inner = (void*)(a & (~1));
22345         a_conv.is_owned = false;
22346         LDKRawDataPart b_conv;
22347         b_conv.inner = (void*)(b & (~1));
22348         b_conv.is_owned = false;
22349         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
22350         return ret_val;
22351 }
22352
22353 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
22354         LDKRawDataPart orig_conv;
22355         orig_conv.inner = (void*)(orig & (~1));
22356         orig_conv.is_owned = false;
22357         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
22358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22360         uint64_t ret_ref = (uint64_t)ret_var.inner;
22361         if (ret_var.is_owned) {
22362                 ret_ref |= 1;
22363         }
22364         return ret_ref;
22365 }
22366
22367 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
22368         LDKPositiveTimestamp this_obj_conv;
22369         this_obj_conv.inner = (void*)(this_obj & (~1));
22370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22371         PositiveTimestamp_free(this_obj_conv);
22372 }
22373
22374 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
22375         LDKPositiveTimestamp a_conv;
22376         a_conv.inner = (void*)(a & (~1));
22377         a_conv.is_owned = false;
22378         LDKPositiveTimestamp b_conv;
22379         b_conv.inner = (void*)(b & (~1));
22380         b_conv.is_owned = false;
22381         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
22382         return ret_val;
22383 }
22384
22385 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
22386         LDKPositiveTimestamp orig_conv;
22387         orig_conv.inner = (void*)(orig & (~1));
22388         orig_conv.is_owned = false;
22389         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
22390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22392         uint64_t ret_ref = (uint64_t)ret_var.inner;
22393         if (ret_var.is_owned) {
22394                 ret_ref |= 1;
22395         }
22396         return ret_ref;
22397 }
22398
22399 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
22400         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
22401         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
22402         return ret_conv;
22403 }
22404
22405 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
22406         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
22407         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
22408         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
22409         return ret_val;
22410 }
22411
22412 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
22413         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
22414         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
22415         return ret_val;
22416 }
22417
22418 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
22419         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
22420         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
22421         return ret_conv;
22422 }
22423
22424 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
22425         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
22426         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
22427         jboolean ret_val = Currency_eq(a_conv, b_conv);
22428         return ret_val;
22429 }
22430
22431 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
22432         LDKSha256 this_obj_conv;
22433         this_obj_conv.inner = (void*)(this_obj & (~1));
22434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22435         Sha256_free(this_obj_conv);
22436 }
22437
22438 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
22439         LDKSha256 a_conv;
22440         a_conv.inner = (void*)(a & (~1));
22441         a_conv.is_owned = false;
22442         LDKSha256 b_conv;
22443         b_conv.inner = (void*)(b & (~1));
22444         b_conv.is_owned = false;
22445         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
22446         return ret_val;
22447 }
22448
22449 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
22450         LDKSha256 orig_conv;
22451         orig_conv.inner = (void*)(orig & (~1));
22452         orig_conv.is_owned = false;
22453         LDKSha256 ret_var = Sha256_clone(&orig_conv);
22454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22456         uint64_t ret_ref = (uint64_t)ret_var.inner;
22457         if (ret_var.is_owned) {
22458                 ret_ref |= 1;
22459         }
22460         return ret_ref;
22461 }
22462
22463 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
22464         LDKDescription this_obj_conv;
22465         this_obj_conv.inner = (void*)(this_obj & (~1));
22466         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22467         Description_free(this_obj_conv);
22468 }
22469
22470 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
22471         LDKDescription a_conv;
22472         a_conv.inner = (void*)(a & (~1));
22473         a_conv.is_owned = false;
22474         LDKDescription b_conv;
22475         b_conv.inner = (void*)(b & (~1));
22476         b_conv.is_owned = false;
22477         jboolean ret_val = Description_eq(&a_conv, &b_conv);
22478         return ret_val;
22479 }
22480
22481 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
22482         LDKDescription orig_conv;
22483         orig_conv.inner = (void*)(orig & (~1));
22484         orig_conv.is_owned = false;
22485         LDKDescription ret_var = Description_clone(&orig_conv);
22486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22488         uint64_t ret_ref = (uint64_t)ret_var.inner;
22489         if (ret_var.is_owned) {
22490                 ret_ref |= 1;
22491         }
22492         return ret_ref;
22493 }
22494
22495 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
22496         LDKPayeePubKey this_obj_conv;
22497         this_obj_conv.inner = (void*)(this_obj & (~1));
22498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22499         PayeePubKey_free(this_obj_conv);
22500 }
22501
22502 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
22503         LDKPayeePubKey a_conv;
22504         a_conv.inner = (void*)(a & (~1));
22505         a_conv.is_owned = false;
22506         LDKPayeePubKey b_conv;
22507         b_conv.inner = (void*)(b & (~1));
22508         b_conv.is_owned = false;
22509         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
22510         return ret_val;
22511 }
22512
22513 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
22514         LDKPayeePubKey orig_conv;
22515         orig_conv.inner = (void*)(orig & (~1));
22516         orig_conv.is_owned = false;
22517         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
22518         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22519         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22520         uint64_t ret_ref = (uint64_t)ret_var.inner;
22521         if (ret_var.is_owned) {
22522                 ret_ref |= 1;
22523         }
22524         return ret_ref;
22525 }
22526
22527 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
22528         LDKExpiryTime this_obj_conv;
22529         this_obj_conv.inner = (void*)(this_obj & (~1));
22530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22531         ExpiryTime_free(this_obj_conv);
22532 }
22533
22534 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
22535         LDKExpiryTime a_conv;
22536         a_conv.inner = (void*)(a & (~1));
22537         a_conv.is_owned = false;
22538         LDKExpiryTime b_conv;
22539         b_conv.inner = (void*)(b & (~1));
22540         b_conv.is_owned = false;
22541         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
22542         return ret_val;
22543 }
22544
22545 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
22546         LDKExpiryTime orig_conv;
22547         orig_conv.inner = (void*)(orig & (~1));
22548         orig_conv.is_owned = false;
22549         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
22550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22552         uint64_t ret_ref = (uint64_t)ret_var.inner;
22553         if (ret_var.is_owned) {
22554                 ret_ref |= 1;
22555         }
22556         return ret_ref;
22557 }
22558
22559 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
22560         LDKMinFinalCltvExpiry this_obj_conv;
22561         this_obj_conv.inner = (void*)(this_obj & (~1));
22562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22563         MinFinalCltvExpiry_free(this_obj_conv);
22564 }
22565
22566 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
22567         LDKMinFinalCltvExpiry a_conv;
22568         a_conv.inner = (void*)(a & (~1));
22569         a_conv.is_owned = false;
22570         LDKMinFinalCltvExpiry b_conv;
22571         b_conv.inner = (void*)(b & (~1));
22572         b_conv.is_owned = false;
22573         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
22574         return ret_val;
22575 }
22576
22577 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
22578         LDKMinFinalCltvExpiry orig_conv;
22579         orig_conv.inner = (void*)(orig & (~1));
22580         orig_conv.is_owned = false;
22581         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
22582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22584         uint64_t ret_ref = (uint64_t)ret_var.inner;
22585         if (ret_var.is_owned) {
22586                 ret_ref |= 1;
22587         }
22588         return ret_ref;
22589 }
22590
22591 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
22592         if ((this_ptr & 1) != 0) return;
22593         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
22594         FREE((void*)this_ptr);
22595         Fallback_free(this_ptr_conv);
22596 }
22597
22598 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
22599         LDKFallback* orig_conv = (LDKFallback*)orig;
22600         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
22601         *ret_copy = Fallback_clone(orig_conv);
22602         uint64_t ret_ref = (uint64_t)ret_copy;
22603         return ret_ref;
22604 }
22605
22606 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
22607         LDKFallback* a_conv = (LDKFallback*)a;
22608         LDKFallback* b_conv = (LDKFallback*)b;
22609         jboolean ret_val = Fallback_eq(a_conv, b_conv);
22610         return ret_val;
22611 }
22612
22613 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
22614         LDKInvoiceSignature this_obj_conv;
22615         this_obj_conv.inner = (void*)(this_obj & (~1));
22616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22617         InvoiceSignature_free(this_obj_conv);
22618 }
22619
22620 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
22621         LDKInvoiceSignature a_conv;
22622         a_conv.inner = (void*)(a & (~1));
22623         a_conv.is_owned = false;
22624         LDKInvoiceSignature b_conv;
22625         b_conv.inner = (void*)(b & (~1));
22626         b_conv.is_owned = false;
22627         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
22628         return ret_val;
22629 }
22630
22631 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
22632         LDKInvoiceSignature orig_conv;
22633         orig_conv.inner = (void*)(orig & (~1));
22634         orig_conv.is_owned = false;
22635         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
22636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22638         uint64_t ret_ref = (uint64_t)ret_var.inner;
22639         if (ret_var.is_owned) {
22640                 ret_ref |= 1;
22641         }
22642         return ret_ref;
22643 }
22644
22645 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
22646         LDKPrivateRoute this_obj_conv;
22647         this_obj_conv.inner = (void*)(this_obj & (~1));
22648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22649         PrivateRoute_free(this_obj_conv);
22650 }
22651
22652 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
22653         LDKPrivateRoute a_conv;
22654         a_conv.inner = (void*)(a & (~1));
22655         a_conv.is_owned = false;
22656         LDKPrivateRoute b_conv;
22657         b_conv.inner = (void*)(b & (~1));
22658         b_conv.is_owned = false;
22659         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
22660         return ret_val;
22661 }
22662
22663 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
22664         LDKPrivateRoute orig_conv;
22665         orig_conv.inner = (void*)(orig & (~1));
22666         orig_conv.is_owned = false;
22667         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
22668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22670         uint64_t ret_ref = (uint64_t)ret_var.inner;
22671         if (ret_var.is_owned) {
22672                 ret_ref |= 1;
22673         }
22674         return ret_ref;
22675 }
22676
22677 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
22678         LDKSignedRawInvoice this_arg_conv;
22679         this_arg_conv.inner = (void*)(this_arg & (~1));
22680         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22681         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
22682         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
22683         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
22684         return (uint64_t)ret_ref;
22685 }
22686
22687 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
22688         LDKSignedRawInvoice this_arg_conv;
22689         this_arg_conv.inner = (void*)(this_arg & (~1));
22690         this_arg_conv.is_owned = false;
22691         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
22692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22694         uint64_t ret_ref = (uint64_t)ret_var.inner;
22695         if (ret_var.is_owned) {
22696                 ret_ref |= 1;
22697         }
22698         return ret_ref;
22699 }
22700
22701 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
22702         LDKSignedRawInvoice this_arg_conv;
22703         this_arg_conv.inner = (void*)(this_arg & (~1));
22704         this_arg_conv.is_owned = false;
22705         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22706         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
22707         return ret_arr;
22708 }
22709
22710 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
22711         LDKSignedRawInvoice this_arg_conv;
22712         this_arg_conv.inner = (void*)(this_arg & (~1));
22713         this_arg_conv.is_owned = false;
22714         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
22715         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22716         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22717         uint64_t ret_ref = (uint64_t)ret_var.inner;
22718         if (ret_var.is_owned) {
22719                 ret_ref |= 1;
22720         }
22721         return ret_ref;
22722 }
22723
22724 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
22725         LDKSignedRawInvoice this_arg_conv;
22726         this_arg_conv.inner = (void*)(this_arg & (~1));
22727         this_arg_conv.is_owned = false;
22728         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
22729         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
22730         return (uint64_t)ret_conv;
22731 }
22732
22733 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
22734         LDKSignedRawInvoice this_arg_conv;
22735         this_arg_conv.inner = (void*)(this_arg & (~1));
22736         this_arg_conv.is_owned = false;
22737         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
22738         return ret_val;
22739 }
22740
22741 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
22742         LDKRawInvoice this_arg_conv;
22743         this_arg_conv.inner = (void*)(this_arg & (~1));
22744         this_arg_conv.is_owned = false;
22745         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22746         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
22747         return ret_arr;
22748 }
22749
22750 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
22751         LDKRawInvoice this_arg_conv;
22752         this_arg_conv.inner = (void*)(this_arg & (~1));
22753         this_arg_conv.is_owned = false;
22754         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
22755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22757         uint64_t ret_ref = (uint64_t)ret_var.inner;
22758         if (ret_var.is_owned) {
22759                 ret_ref |= 1;
22760         }
22761         return ret_ref;
22762 }
22763
22764 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
22765         LDKRawInvoice this_arg_conv;
22766         this_arg_conv.inner = (void*)(this_arg & (~1));
22767         this_arg_conv.is_owned = false;
22768         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
22769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22771         uint64_t ret_ref = (uint64_t)ret_var.inner;
22772         if (ret_var.is_owned) {
22773                 ret_ref |= 1;
22774         }
22775         return ret_ref;
22776 }
22777
22778 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
22779         LDKRawInvoice this_arg_conv;
22780         this_arg_conv.inner = (void*)(this_arg & (~1));
22781         this_arg_conv.is_owned = false;
22782         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
22783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22785         uint64_t ret_ref = (uint64_t)ret_var.inner;
22786         if (ret_var.is_owned) {
22787                 ret_ref |= 1;
22788         }
22789         return ret_ref;
22790 }
22791
22792 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
22793         LDKRawInvoice this_arg_conv;
22794         this_arg_conv.inner = (void*)(this_arg & (~1));
22795         this_arg_conv.is_owned = false;
22796         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
22797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22799         uint64_t ret_ref = (uint64_t)ret_var.inner;
22800         if (ret_var.is_owned) {
22801                 ret_ref |= 1;
22802         }
22803         return ret_ref;
22804 }
22805
22806 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
22807         LDKRawInvoice this_arg_conv;
22808         this_arg_conv.inner = (void*)(this_arg & (~1));
22809         this_arg_conv.is_owned = false;
22810         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
22811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22813         uint64_t ret_ref = (uint64_t)ret_var.inner;
22814         if (ret_var.is_owned) {
22815                 ret_ref |= 1;
22816         }
22817         return ret_ref;
22818 }
22819
22820 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
22821         LDKRawInvoice this_arg_conv;
22822         this_arg_conv.inner = (void*)(this_arg & (~1));
22823         this_arg_conv.is_owned = false;
22824         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
22825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22827         uint64_t ret_ref = (uint64_t)ret_var.inner;
22828         if (ret_var.is_owned) {
22829                 ret_ref |= 1;
22830         }
22831         return ret_ref;
22832 }
22833
22834 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
22835         LDKRawInvoice this_arg_conv;
22836         this_arg_conv.inner = (void*)(this_arg & (~1));
22837         this_arg_conv.is_owned = false;
22838         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22839         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
22840         return ret_arr;
22841 }
22842
22843 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
22844         LDKRawInvoice this_arg_conv;
22845         this_arg_conv.inner = (void*)(this_arg & (~1));
22846         this_arg_conv.is_owned = false;
22847         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
22848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22850         uint64_t ret_ref = (uint64_t)ret_var.inner;
22851         if (ret_var.is_owned) {
22852                 ret_ref |= 1;
22853         }
22854         return ret_ref;
22855 }
22856
22857 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
22858         LDKRawInvoice this_arg_conv;
22859         this_arg_conv.inner = (void*)(this_arg & (~1));
22860         this_arg_conv.is_owned = false;
22861         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
22862         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22863         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22864         for (size_t o = 0; o < ret_var.datalen; o++) {
22865                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22866                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22867                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22868                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22869                 if (ret_conv_14_var.is_owned) {
22870                         ret_conv_14_ref |= 1;
22871                 }
22872                 ret_arr_ptr[o] = ret_conv_14_ref;
22873         }
22874         FREE(ret_var.data);
22875         return ret_arr;
22876 }
22877
22878 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
22879         LDKRawInvoice this_arg_conv;
22880         this_arg_conv.inner = (void*)(this_arg & (~1));
22881         this_arg_conv.is_owned = false;
22882         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22883         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
22884         uint64_t ret_ref = (uint64_t)ret_copy;
22885         return ret_ref;
22886 }
22887
22888 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
22889         LDKRawInvoice this_arg_conv;
22890         this_arg_conv.inner = (void*)(this_arg & (~1));
22891         this_arg_conv.is_owned = false;
22892         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
22893         return ret_conv;
22894 }
22895
22896 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
22897         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22898         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
22899         return (uint64_t)ret_conv;
22900 }
22901
22902 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
22903         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22904         *ret_conv = PositiveTimestamp_from_system_time(time);
22905         return (uint64_t)ret_conv;
22906 }
22907
22908 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
22909         LDKPositiveTimestamp this_arg_conv;
22910         this_arg_conv.inner = (void*)(this_arg & (~1));
22911         this_arg_conv.is_owned = false;
22912         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
22913         return ret_val;
22914 }
22915
22916 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
22917         LDKPositiveTimestamp this_arg_conv;
22918         this_arg_conv.inner = (void*)(this_arg & (~1));
22919         this_arg_conv.is_owned = false;
22920         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
22921         return ret_val;
22922 }
22923
22924 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
22925         LDKInvoice this_arg_conv;
22926         this_arg_conv.inner = (void*)(this_arg & (~1));
22927         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22928         this_arg_conv = Invoice_clone(&this_arg_conv);
22929         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
22930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22932         uint64_t ret_ref = (uint64_t)ret_var.inner;
22933         if (ret_var.is_owned) {
22934                 ret_ref |= 1;
22935         }
22936         return ret_ref;
22937 }
22938
22939 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
22940         LDKInvoice this_arg_conv;
22941         this_arg_conv.inner = (void*)(this_arg & (~1));
22942         this_arg_conv.is_owned = false;
22943         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
22944         *ret_conv = Invoice_check_signature(&this_arg_conv);
22945         return (uint64_t)ret_conv;
22946 }
22947
22948 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
22949         LDKSignedRawInvoice signed_invoice_conv;
22950         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
22951         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
22952         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
22953         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
22954         *ret_conv = Invoice_from_signed(signed_invoice_conv);
22955         return (uint64_t)ret_conv;
22956 }
22957
22958 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
22959         LDKInvoice this_arg_conv;
22960         this_arg_conv.inner = (void*)(this_arg & (~1));
22961         this_arg_conv.is_owned = false;
22962         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
22963         return ret_val;
22964 }
22965
22966 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
22967         LDKInvoice this_arg_conv;
22968         this_arg_conv.inner = (void*)(this_arg & (~1));
22969         this_arg_conv.is_owned = false;
22970         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22971         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
22972         return ret_arr;
22973 }
22974
22975 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
22976         LDKInvoice this_arg_conv;
22977         this_arg_conv.inner = (void*)(this_arg & (~1));
22978         this_arg_conv.is_owned = false;
22979         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22980         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
22981         return ret_arr;
22982 }
22983
22984 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
22985         LDKInvoice this_arg_conv;
22986         this_arg_conv.inner = (void*)(this_arg & (~1));
22987         this_arg_conv.is_owned = false;
22988         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22989         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
22990         return ret_arr;
22991 }
22992
22993 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
22994         LDKInvoice this_arg_conv;
22995         this_arg_conv.inner = (void*)(this_arg & (~1));
22996         this_arg_conv.is_owned = false;
22997         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
22998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23000         uint64_t ret_ref = (uint64_t)ret_var.inner;
23001         if (ret_var.is_owned) {
23002                 ret_ref |= 1;
23003         }
23004         return ret_ref;
23005 }
23006
23007 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
23008         LDKInvoice this_arg_conv;
23009         this_arg_conv.inner = (void*)(this_arg & (~1));
23010         this_arg_conv.is_owned = false;
23011         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23012         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
23013         return ret_arr;
23014 }
23015
23016 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
23017         LDKInvoice this_arg_conv;
23018         this_arg_conv.inner = (void*)(this_arg & (~1));
23019         this_arg_conv.is_owned = false;
23020         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
23021         return ret_val;
23022 }
23023
23024 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
23025         LDKInvoice this_arg_conv;
23026         this_arg_conv.inner = (void*)(this_arg & (~1));
23027         this_arg_conv.is_owned = false;
23028         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
23029         return ret_val;
23030 }
23031
23032 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
23033         LDKInvoice this_arg_conv;
23034         this_arg_conv.inner = (void*)(this_arg & (~1));
23035         this_arg_conv.is_owned = false;
23036         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
23037         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23038         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
23039         for (size_t o = 0; o < ret_var.datalen; o++) {
23040                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
23041                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23042                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23043                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
23044                 if (ret_conv_14_var.is_owned) {
23045                         ret_conv_14_ref |= 1;
23046                 }
23047                 ret_arr_ptr[o] = ret_conv_14_ref;
23048         }
23049         FREE(ret_var.data);
23050         return ret_arr;
23051 }
23052
23053 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
23054         LDKInvoice this_arg_conv;
23055         this_arg_conv.inner = (void*)(this_arg & (~1));
23056         this_arg_conv.is_owned = false;
23057         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
23058         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23059         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
23060         for (size_t l = 0; l < ret_var.datalen; l++) {
23061                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
23062                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23063                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23064                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
23065                 if (ret_conv_11_var.is_owned) {
23066                         ret_conv_11_ref |= 1;
23067                 }
23068                 ret_arr_ptr[l] = ret_conv_11_ref;
23069         }
23070         FREE(ret_var.data);
23071         return ret_arr;
23072 }
23073
23074 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
23075         LDKInvoice this_arg_conv;
23076         this_arg_conv.inner = (void*)(this_arg & (~1));
23077         this_arg_conv.is_owned = false;
23078         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
23079         return ret_conv;
23080 }
23081
23082 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
23083         LDKInvoice this_arg_conv;
23084         this_arg_conv.inner = (void*)(this_arg & (~1));
23085         this_arg_conv.is_owned = false;
23086         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23087         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
23088         uint64_t ret_ref = (uint64_t)ret_copy;
23089         return ret_ref;
23090 }
23091
23092 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
23093         LDKStr description_conv = str_ref_to_owned_c(description);
23094         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23095         *ret_conv = Description_new(description_conv);
23096         return (uint64_t)ret_conv;
23097 }
23098
23099 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
23100         LDKDescription this_arg_conv;
23101         this_arg_conv.inner = (void*)(this_arg & (~1));
23102         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23103         this_arg_conv = Description_clone(&this_arg_conv);
23104         LDKStr ret_str = Description_into_inner(this_arg_conv);
23105         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23106         return ret_conv;
23107 }
23108
23109 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
23110         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
23111         *ret_conv = ExpiryTime_from_seconds(seconds);
23112         return (uint64_t)ret_conv;
23113 }
23114
23115 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
23116         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
23117         *ret_conv = ExpiryTime_from_duration(duration);
23118         return (uint64_t)ret_conv;
23119 }
23120
23121 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
23122         LDKExpiryTime this_arg_conv;
23123         this_arg_conv.inner = (void*)(this_arg & (~1));
23124         this_arg_conv.is_owned = false;
23125         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
23126         return ret_val;
23127 }
23128
23129 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
23130         LDKExpiryTime this_arg_conv;
23131         this_arg_conv.inner = (void*)(this_arg & (~1));
23132         this_arg_conv.is_owned = false;
23133         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
23134         return ret_val;
23135 }
23136
23137 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
23138         LDKRouteHint hops_conv;
23139         hops_conv.inner = (void*)(hops & (~1));
23140         hops_conv.is_owned = (hops & 1) || (hops == 0);
23141         hops_conv = RouteHint_clone(&hops_conv);
23142         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23143         *ret_conv = PrivateRoute_new(hops_conv);
23144         return (uint64_t)ret_conv;
23145 }
23146
23147 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
23148         LDKPrivateRoute this_arg_conv;
23149         this_arg_conv.inner = (void*)(this_arg & (~1));
23150         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23151         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
23152         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
23153         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23154         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23155         uint64_t ret_ref = (uint64_t)ret_var.inner;
23156         if (ret_var.is_owned) {
23157                 ret_ref |= 1;
23158         }
23159         return ret_ref;
23160 }
23161
23162 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
23163         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
23164         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
23165         return ret_conv;
23166 }
23167
23168 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
23169         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
23170         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
23171         jboolean ret_val = CreationError_eq(a_conv, b_conv);
23172         return ret_val;
23173 }
23174
23175 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
23176         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
23177         LDKStr ret_str = CreationError_to_str(o_conv);
23178         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23179         return ret_conv;
23180 }
23181
23182 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
23183         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
23184         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
23185         return ret_conv;
23186 }
23187
23188 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
23189         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
23190         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
23191         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
23192         return ret_val;
23193 }
23194
23195 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
23196         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
23197         LDKStr ret_str = SemanticError_to_str(o_conv);
23198         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23199         return ret_conv;
23200 }
23201
23202 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
23203         if ((this_ptr & 1) != 0) return;
23204         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
23205         FREE((void*)this_ptr);
23206         SignOrCreationError_free(this_ptr_conv);
23207 }
23208
23209 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
23210         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
23211         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
23212         *ret_copy = SignOrCreationError_clone(orig_conv);
23213         uint64_t ret_ref = (uint64_t)ret_copy;
23214         return ret_ref;
23215 }
23216
23217 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
23218         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
23219         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
23220         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
23221         return ret_val;
23222 }
23223
23224 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
23225         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
23226         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
23227         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23228         return ret_conv;
23229 }
23230
23231 uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelmanager(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description) {
23232         LDKChannelManager channelmanager_conv;
23233         channelmanager_conv.inner = (void*)(channelmanager & (~1));
23234         channelmanager_conv.is_owned = false;
23235         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
23236         LDKCurrency network_conv = LDKCurrency_from_js(network);
23237         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
23238         LDKStr description_conv = str_ref_to_owned_c(description);
23239         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23240         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
23241         return (uint64_t)ret_conv;
23242 }
23243
23244 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
23245         LDKStr s_conv = str_ref_to_owned_c(s);
23246         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
23247         *ret_conv = SiPrefix_from_str(s_conv);
23248         return (uint64_t)ret_conv;
23249 }
23250
23251 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
23252         LDKStr s_conv = str_ref_to_owned_c(s);
23253         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
23254         *ret_conv = Invoice_from_str(s_conv);
23255         return (uint64_t)ret_conv;
23256 }
23257
23258 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
23259         LDKStr s_conv = str_ref_to_owned_c(s);
23260         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
23261         *ret_conv = SignedRawInvoice_from_str(s_conv);
23262         return (uint64_t)ret_conv;
23263 }
23264
23265 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
23266         LDKInvoice o_conv;
23267         o_conv.inner = (void*)(o & (~1));
23268         o_conv.is_owned = false;
23269         LDKStr ret_str = Invoice_to_str(&o_conv);
23270         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23271         return ret_conv;
23272 }
23273
23274 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
23275         LDKSignedRawInvoice o_conv;
23276         o_conv.inner = (void*)(o & (~1));
23277         o_conv.is_owned = false;
23278         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
23279         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23280         return ret_conv;
23281 }
23282
23283 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
23284         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
23285         LDKStr ret_str = Currency_to_str(o_conv);
23286         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23287         return ret_conv;
23288 }
23289
23290 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
23291         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
23292         LDKStr ret_str = SiPrefix_to_str(o_conv);
23293         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23294         return ret_conv;
23295 }
23296