dd99fe3c31ea39728b58a8bc922cd80e90d27a73
[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_Off;
201                 case 1: return LDKLevel_Error;
202                 case 2: return LDKLevel_Warn;
203                 case 3: return LDKLevel_Info;
204                 case 4: return LDKLevel_Debug;
205                 case 5: return LDKLevel_Trace;
206         }
207         abort();
208 }
209 static inline int32_t LDKLevel_to_js(LDKLevel val) {
210         switch (val) {
211                 case LDKLevel_Off: return 0;
212                 case LDKLevel_Error: return 1;
213                 case LDKLevel_Warn: return 2;
214                 case LDKLevel_Info: return 3;
215                 case LDKLevel_Debug: return 4;
216                 case LDKLevel_Trace: return 5;
217                 default: abort();
218         }
219 }
220 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
221         switch (ord) {
222                 case 0: return LDKNetwork_Bitcoin;
223                 case 1: return LDKNetwork_Testnet;
224                 case 2: return LDKNetwork_Regtest;
225                 case 3: return LDKNetwork_Signet;
226         }
227         abort();
228 }
229 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
230         switch (val) {
231                 case LDKNetwork_Bitcoin: return 0;
232                 case LDKNetwork_Testnet: return 1;
233                 case LDKNetwork_Regtest: return 2;
234                 case LDKNetwork_Signet: return 3;
235                 default: abort();
236         }
237 }
238 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
239         switch (ord) {
240                 case 0: return LDKSecp256k1Error_IncorrectSignature;
241                 case 1: return LDKSecp256k1Error_InvalidMessage;
242                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
243                 case 3: return LDKSecp256k1Error_InvalidSignature;
244                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
245                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
246                 case 6: return LDKSecp256k1Error_InvalidTweak;
247                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
248                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
249         }
250         abort();
251 }
252 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
253         switch (val) {
254                 case LDKSecp256k1Error_IncorrectSignature: return 0;
255                 case LDKSecp256k1Error_InvalidMessage: return 1;
256                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
257                 case LDKSecp256k1Error_InvalidSignature: return 3;
258                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
259                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
260                 case LDKSecp256k1Error_InvalidTweak: return 6;
261                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
262                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
263                 default: abort();
264         }
265 }
266 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
267         switch (ord) {
268                 case 0: return LDKSemanticError_NoPaymentHash;
269                 case 1: return LDKSemanticError_MultiplePaymentHashes;
270                 case 2: return LDKSemanticError_NoDescription;
271                 case 3: return LDKSemanticError_MultipleDescriptions;
272                 case 4: return LDKSemanticError_MultiplePaymentSecrets;
273                 case 5: return LDKSemanticError_InvalidFeatures;
274                 case 6: return LDKSemanticError_InvalidRecoveryId;
275                 case 7: return LDKSemanticError_InvalidSignature;
276         }
277         abort();
278 }
279 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
280         switch (val) {
281                 case LDKSemanticError_NoPaymentHash: return 0;
282                 case LDKSemanticError_MultiplePaymentHashes: return 1;
283                 case LDKSemanticError_NoDescription: return 2;
284                 case LDKSemanticError_MultipleDescriptions: return 3;
285                 case LDKSemanticError_MultiplePaymentSecrets: return 4;
286                 case LDKSemanticError_InvalidFeatures: return 5;
287                 case LDKSemanticError_InvalidRecoveryId: return 6;
288                 case LDKSemanticError_InvalidSignature: return 7;
289                 default: abort();
290         }
291 }
292 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
293         switch (ord) {
294                 case 0: return LDKSiPrefix_Milli;
295                 case 1: return LDKSiPrefix_Micro;
296                 case 2: return LDKSiPrefix_Nano;
297                 case 3: return LDKSiPrefix_Pico;
298         }
299         abort();
300 }
301 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
302         switch (val) {
303                 case LDKSiPrefix_Milli: return 0;
304                 case LDKSiPrefix_Micro: return 1;
305                 case LDKSiPrefix_Nano: return 2;
306                 case LDKSiPrefix_Pico: return 3;
307                 default: abort();
308         }
309 }
310 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
311         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
312         ret->datalen = *((uint32_t*)elems);
313         if (ret->datalen == 0) {
314                 ret->data = NULL;
315         } else {
316                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
317                 int8_t *java_elems = (int8_t*)(elems + 4);
318                 for (size_t i = 0; i < ret->datalen; i++) {
319                         ret->data[i] = java_elems[i];
320                 }
321         }
322         return (uint64_t)ret;
323 }
324 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
325         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
326         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
327         return ret;
328 }
329 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
330         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
331 }
332 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
333         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
334         CHECK(val->result_ok);
335         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
336         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
337         return res_arr;
338 }
339 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
340         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
341         CHECK(!val->result_ok);
342         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
343         return err_conv;
344 }
345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
346         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
347 }
348 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
349         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
350         CHECK(val->result_ok);
351         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
352         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
353         return res_arr;
354 }
355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
356         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
357         CHECK(!val->result_ok);
358         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
359         return err_conv;
360 }
361 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
362         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
363 }
364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
365         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
366         CHECK(val->result_ok);
367         LDKTxCreationKeys res_var = (*val->contents.result);
368         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
369         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
370         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
371         return res_ref;
372 }
373 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
374         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
375         CHECK(!val->result_ok);
376         LDKDecodeError err_var = (*val->contents.err);
377         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
378         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
379         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
380         return err_ref;
381 }
382 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
383         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
384 }
385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
386         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
387         CHECK(val->result_ok);
388         LDKChannelPublicKeys res_var = (*val->contents.result);
389         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
390         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
391         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
392         return res_ref;
393 }
394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
395         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
396         CHECK(!val->result_ok);
397         LDKDecodeError err_var = (*val->contents.err);
398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
400         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
401         return err_ref;
402 }
403 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
404         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
405 }
406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
407         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
408         CHECK(val->result_ok);
409         LDKTxCreationKeys res_var = (*val->contents.result);
410         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
411         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
412         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
413         return res_ref;
414 }
415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
416         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
417         CHECK(!val->result_ok);
418         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
419         return err_conv;
420 }
421 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
422         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
423         switch(obj->tag) {
424                 case LDKCOption_u32Z_Some: {
425                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
426                 }
427                 case LDKCOption_u32Z_None: {
428                         return 0 /* LDKCOption_u32Z - None */;
429                 }
430                 default: abort();
431         }
432 }
433 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
434         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
435 }
436 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
437         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
438         CHECK(val->result_ok);
439         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
440         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
441         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
442         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
443         return res_ref;
444 }
445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
446         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
447         CHECK(!val->result_ok);
448         LDKDecodeError err_var = (*val->contents.err);
449         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
450         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
451         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
452         return err_ref;
453 }
454 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
455         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
456 }
457 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
458         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
459         CHECK(val->result_ok);
460         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
461         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
464         return res_ref;
465 }
466 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
467         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
468         CHECK(!val->result_ok);
469         LDKDecodeError err_var = (*val->contents.err);
470         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
471         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
472         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
473         return err_ref;
474 }
475 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
476         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
477 }
478 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
479         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
480         CHECK(val->result_ok);
481         LDKChannelTransactionParameters res_var = (*val->contents.result);
482         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
483         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
484         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
485         return res_ref;
486 }
487 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
488         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
489         CHECK(!val->result_ok);
490         LDKDecodeError err_var = (*val->contents.err);
491         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
492         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
493         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
494         return err_ref;
495 }
496 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
497         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
498 }
499 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
500         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
501         CHECK(val->result_ok);
502         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
503         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
504         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
505         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
506         return res_ref;
507 }
508 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
509         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
510         CHECK(!val->result_ok);
511         LDKDecodeError err_var = (*val->contents.err);
512         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
513         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
514         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
515         return err_ref;
516 }
517 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
518         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
519 }
520 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
521         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
522         CHECK(val->result_ok);
523         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
524         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
527         return res_ref;
528 }
529 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
530         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
531         CHECK(!val->result_ok);
532         LDKDecodeError err_var = (*val->contents.err);
533         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
534         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
535         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
536         return err_ref;
537 }
538 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
539         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
540 }
541 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
542         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
543         CHECK(val->result_ok);
544         LDKCommitmentTransaction res_var = (*val->contents.result);
545         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
546         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
547         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
548         return res_ref;
549 }
550 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
551         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
552         CHECK(!val->result_ok);
553         LDKDecodeError err_var = (*val->contents.err);
554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
556         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
557         return err_ref;
558 }
559 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
560         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
561 }
562 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
563         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
564         CHECK(val->result_ok);
565         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
568         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
569         return res_ref;
570 }
571 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
572         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
573         CHECK(!val->result_ok);
574         return *val->contents.err;
575 }
576 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
577         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
578 }
579 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
580         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
581         CHECK(val->result_ok);
582         LDKCVec_SignatureZ res_var = (*val->contents.result);
583         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
584         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
585         for (size_t m = 0; m < res_var.datalen; m++) {
586                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
587                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
588                 res_arr_ptr[m] = res_conv_12_arr;
589         }
590         return res_arr;
591 }
592 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
593         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
594         CHECK(!val->result_ok);
595         return *val->contents.err;
596 }
597 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
598         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
599 }
600 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
601         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
602         CHECK(val->result_ok);
603         return *val->contents.result;
604 }
605 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
606         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
607         CHECK(!val->result_ok);
608         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
609         return err_conv;
610 }
611 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
612         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
613 }
614 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
615         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
616         CHECK(val->result_ok);
617         LDKRouteHop res_var = (*val->contents.result);
618         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
619         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
620         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
621         return res_ref;
622 }
623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
624         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
625         CHECK(!val->result_ok);
626         LDKDecodeError err_var = (*val->contents.err);
627         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
628         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
629         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
630         return err_ref;
631 }
632 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
633         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
634         ret->datalen = *((uint32_t*)elems);
635         if (ret->datalen == 0) {
636                 ret->data = NULL;
637         } else {
638                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
639                 uint32_t *java_elems = (uint32_t*)(elems + 4);
640                 for (size_t i = 0; i < ret->datalen; i++) {
641                         uint32_t arr_elem = java_elems[i];
642                         LDKRouteHop arr_elem_conv;
643                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
644                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
645                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
646                         ret->data[i] = arr_elem_conv;
647                 }
648         }
649         return (uint64_t)ret;
650 }
651 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
652         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
653         for (size_t i = 0; i < ret.datalen; i++) {
654                 ret.data[i] = RouteHop_clone(&orig->data[i]);
655         }
656         return ret;
657 }
658 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
659         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
660         for (size_t i = 0; i < ret.datalen; i++) {
661                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
662         }
663         return ret;
664 }
665 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
666         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
667 }
668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
669         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
670         CHECK(val->result_ok);
671         LDKRoute res_var = (*val->contents.result);
672         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
673         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
674         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
675         return res_ref;
676 }
677 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
678         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
679         CHECK(!val->result_ok);
680         LDKDecodeError err_var = (*val->contents.err);
681         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
682         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
683         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
684         return err_ref;
685 }
686 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
687         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
688         switch(obj->tag) {
689                 case LDKCOption_u64Z_Some: {
690                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
691                 }
692                 case LDKCOption_u64Z_None: {
693                         return 0 /* LDKCOption_u64Z - None */;
694                 }
695                 default: abort();
696         }
697 }
698 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
699         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
700         ret->datalen = *((uint32_t*)elems);
701         if (ret->datalen == 0) {
702                 ret->data = NULL;
703         } else {
704                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
705                 uint32_t *java_elems = (uint32_t*)(elems + 4);
706                 for (size_t i = 0; i < ret->datalen; i++) {
707                         uint32_t arr_elem = java_elems[i];
708                         LDKChannelDetails arr_elem_conv;
709                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
710                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
711                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
712                         ret->data[i] = arr_elem_conv;
713                 }
714         }
715         return (uint64_t)ret;
716 }
717 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
718         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
719         for (size_t i = 0; i < ret.datalen; i++) {
720                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
721         }
722         return ret;
723 }
724 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
725         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
726         ret->datalen = *((uint32_t*)elems);
727         if (ret->datalen == 0) {
728                 ret->data = NULL;
729         } else {
730                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
731                 uint32_t *java_elems = (uint32_t*)(elems + 4);
732                 for (size_t i = 0; i < ret->datalen; i++) {
733                         uint32_t arr_elem = java_elems[i];
734                         LDKRouteHint arr_elem_conv;
735                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
736                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
737                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
738                         ret->data[i] = arr_elem_conv;
739                 }
740         }
741         return (uint64_t)ret;
742 }
743 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
744         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
745         for (size_t i = 0; i < ret.datalen; i++) {
746                 ret.data[i] = RouteHint_clone(&orig->data[i]);
747         }
748         return ret;
749 }
750 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
751         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
752 }
753 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
754         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
755         CHECK(val->result_ok);
756         LDKRoute res_var = (*val->contents.result);
757         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
758         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
759         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
760         return res_ref;
761 }
762 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
763         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
764         CHECK(!val->result_ok);
765         LDKLightningError err_var = (*val->contents.err);
766         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
767         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
768         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
769         return err_ref;
770 }
771 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
772         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
773 }
774 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
775         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
776         CHECK(val->result_ok);
777         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
778         return (uint64_t)res_ref;
779 }
780 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
781         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
782         CHECK(!val->result_ok);
783         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
784         return err_conv;
785 }
786 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
787         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
788         ret->a = a;
789         LDKTransaction b_ref;
790         b_ref.datalen = *((uint32_t*)b);
791         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
792         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
793         b_ref.data_is_owned = false;
794         ret->b = b_ref;
795         return (uint64_t)ret;
796 }
797 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
798         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
799         return tuple->a;
800 }
801 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
802         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
803         LDKTransaction b_var = tuple->b;
804         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
805         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
806         return b_arr;
807 }
808 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
809         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
810         ret->datalen = *((uint32_t*)elems);
811         if (ret->datalen == 0) {
812                 ret->data = NULL;
813         } else {
814                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
815                 uint32_t *java_elems = (uint32_t*)(elems + 4);
816                 for (size_t i = 0; i < ret->datalen; i++) {
817                         uint32_t arr_elem = java_elems[i];
818                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
819                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
820                         ret->data[i] = arr_elem_conv;
821                 }
822         }
823         return (uint64_t)ret;
824 }
825 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
826         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
827         for (size_t i = 0; i < ret.datalen; i++) {
828                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
829         }
830         return ret;
831 }
832 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
833         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
834         for (size_t i = 0; i < ret.datalen; i++) {
835                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
836         }
837         return ret;
838 }
839 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
840         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
841 }
842 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
843         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
844         CHECK(val->result_ok);
845         return *val->contents.result;
846 }
847 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
848         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
849         CHECK(!val->result_ok);
850         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
851         return err_conv;
852 }
853 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
854         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
855         switch(obj->tag) {
856                 case LDKMonitorEvent_HTLCEvent: {
857                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
858                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
861                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
862                 }
863                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
864                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
865                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
866                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
867                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
868                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */; (void) commitment_tx_broadcasted_ref;
869                 }
870                 default: abort();
871         }
872 }
873 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
874         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
875         ret->datalen = *((uint32_t*)elems);
876         if (ret->datalen == 0) {
877                 ret->data = NULL;
878         } else {
879                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
880                 uint32_t *java_elems = (uint32_t*)(elems + 4);
881                 for (size_t i = 0; i < ret->datalen; i++) {
882                         uint32_t arr_elem = java_elems[i];
883                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
884                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
885                         ret->data[i] = arr_elem_conv;
886                 }
887         }
888         return (uint64_t)ret;
889 }
890 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
891         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
892         for (size_t i = 0; i < ret.datalen; i++) {
893                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
894         }
895         return ret;
896 }
897 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
898         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
899         switch(obj->tag) {
900                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
901                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
902                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) some_ref;
903                 }
904                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
905                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
906                 }
907                 default: abort();
908         }
909 }
910 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
911         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
912         switch(obj->tag) {
913                 case LDKSpendableOutputDescriptor_StaticOutput: {
914                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
915                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
916                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
917                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
918                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
919                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
920                 }
921                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
922                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
923                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
926                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
927                 }
928                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
929                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
930                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
933                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
934                 }
935                 default: abort();
936         }
937 }
938 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
939         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
940         ret->datalen = *((uint32_t*)elems);
941         if (ret->datalen == 0) {
942                 ret->data = NULL;
943         } else {
944                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
945                 uint32_t *java_elems = (uint32_t*)(elems + 4);
946                 for (size_t i = 0; i < ret->datalen; i++) {
947                         uint32_t arr_elem = java_elems[i];
948                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
949                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
950                         ret->data[i] = arr_elem_conv;
951                 }
952         }
953         return (uint64_t)ret;
954 }
955 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
956         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
957         for (size_t i = 0; i < ret.datalen; i++) {
958                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
959         }
960         return ret;
961 }
962 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
963         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
964         switch(obj->tag) {
965                 case LDKErrorAction_DisconnectPeer: {
966                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
967                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
968                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
969                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
970                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
971                 }
972                 case LDKErrorAction_IgnoreError: {
973                         return 0 /* LDKErrorAction - IgnoreError */;
974                 }
975                 case LDKErrorAction_SendErrorMessage: {
976                         LDKErrorMessage msg_var = obj->send_error_message.msg;
977                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
978                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
979                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
980                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
981                 }
982                 default: abort();
983         }
984 }
985 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
986         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
987         switch(obj->tag) {
988                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
989                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
990                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
991                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
992                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
993                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
994                 }
995                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
996                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
997                 }
998                 case LDKHTLCFailChannelUpdate_NodeFailure: {
999                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1000                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1001                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1002                 }
1003                 default: abort();
1004         }
1005 }
1006 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1007         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1008         switch(obj->tag) {
1009                 case LDKMessageSendEvent_SendAcceptChannel: {
1010                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1011                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1012                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1013                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1014                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1015                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1016                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1017                 }
1018                 case LDKMessageSendEvent_SendOpenChannel: {
1019                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1020                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1021                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1022                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1023                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1024                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1025                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1026                 }
1027                 case LDKMessageSendEvent_SendFundingCreated: {
1028                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1029                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1030                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1031                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1032                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1033                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1034                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1035                 }
1036                 case LDKMessageSendEvent_SendFundingSigned: {
1037                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1038                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1039                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1040                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1041                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1042                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1043                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1044                 }
1045                 case LDKMessageSendEvent_SendFundingLocked: {
1046                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1047                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1048                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1049                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1050                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1051                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1052                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1053                 }
1054                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1055                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1056                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1057                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1058                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1059                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1060                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1061                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1062                 }
1063                 case LDKMessageSendEvent_UpdateHTLCs: {
1064                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1065                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1066                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1067                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1068                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1069                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1070                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1071                 }
1072                 case LDKMessageSendEvent_SendRevokeAndACK: {
1073                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1074                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1075                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1076                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1077                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1078                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1079                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1080                 }
1081                 case LDKMessageSendEvent_SendClosingSigned: {
1082                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1083                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1084                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1085                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1086                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1087                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1088                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1089                 }
1090                 case LDKMessageSendEvent_SendShutdown: {
1091                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1092                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1093                         LDKShutdown msg_var = obj->send_shutdown.msg;
1094                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1095                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1096                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1097                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1098                 }
1099                 case LDKMessageSendEvent_SendChannelReestablish: {
1100                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1101                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1102                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1103                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1104                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1105                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1106                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1107                 }
1108                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1109                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1110                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1113                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1114                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1115                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1116                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1117                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1118                 }
1119                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1120                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1121                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1122                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1123                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1124                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1125                 }
1126                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1127                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1128                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1131                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1132                 }
1133                 case LDKMessageSendEvent_HandleError: {
1134                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1135                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1136                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1137                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1138                 }
1139                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1140                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1141                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
1142                 }
1143                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1144                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1145                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1146                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1147                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1148                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1149                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1150                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1151                 }
1152                 case LDKMessageSendEvent_SendShortIdsQuery: {
1153                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1154                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1155                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1156                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1157                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1158                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1159                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1160                 }
1161                 case LDKMessageSendEvent_SendReplyChannelRange: {
1162                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1163                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1164                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1165                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1166                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1167                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1168                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1169                 }
1170                 default: abort();
1171         }
1172 }
1173 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1174         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1175         ret->datalen = *((uint32_t*)elems);
1176         if (ret->datalen == 0) {
1177                 ret->data = NULL;
1178         } else {
1179                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1180                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1181                 for (size_t i = 0; i < ret->datalen; i++) {
1182                         uint32_t arr_elem = java_elems[i];
1183                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1184                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1185                         ret->data[i] = arr_elem_conv;
1186                 }
1187         }
1188         return (uint64_t)ret;
1189 }
1190 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1191         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1192         for (size_t i = 0; i < ret.datalen; i++) {
1193                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1194         }
1195         return ret;
1196 }
1197 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1198         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1199 }
1200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1201         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1202         CHECK(val->result_ok);
1203         LDKInitFeatures res_var = (*val->contents.result);
1204         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1205         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1206         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1207         return res_ref;
1208 }
1209 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1210         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1211         CHECK(!val->result_ok);
1212         LDKDecodeError err_var = (*val->contents.err);
1213         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1214         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1215         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1216         return err_ref;
1217 }
1218 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1219         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1220 }
1221 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1222         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1223         CHECK(val->result_ok);
1224         LDKNodeFeatures res_var = (*val->contents.result);
1225         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1226         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1227         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1228         return res_ref;
1229 }
1230 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1231         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1232         CHECK(!val->result_ok);
1233         LDKDecodeError err_var = (*val->contents.err);
1234         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1235         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1236         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1237         return err_ref;
1238 }
1239 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1240         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1241 }
1242 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1243         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1244         CHECK(val->result_ok);
1245         LDKChannelFeatures res_var = (*val->contents.result);
1246         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1247         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1248         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1249         return res_ref;
1250 }
1251 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1252         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1253         CHECK(!val->result_ok);
1254         LDKDecodeError err_var = (*val->contents.err);
1255         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1256         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1257         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1258         return err_ref;
1259 }
1260 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1261         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1262 }
1263 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1264         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1265         CHECK(val->result_ok);
1266         LDKInvoiceFeatures res_var = (*val->contents.result);
1267         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1268         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1269         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1270         return res_ref;
1271 }
1272 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1273         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1274         CHECK(!val->result_ok);
1275         LDKDecodeError err_var = (*val->contents.err);
1276         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1277         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1278         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1279         return err_ref;
1280 }
1281 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1282         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1283 }
1284 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1285         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1286         CHECK(val->result_ok);
1287         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1288         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1289         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1290         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1291         return res_ref;
1292 }
1293 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1294         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1295         CHECK(!val->result_ok);
1296         LDKDecodeError err_var = (*val->contents.err);
1297         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1298         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1299         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1300         return err_ref;
1301 }
1302 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1303         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1304 }
1305 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1306         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1307         CHECK(val->result_ok);
1308         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1309         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1310         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1311         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1312         return res_ref;
1313 }
1314 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1315         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1316         CHECK(!val->result_ok);
1317         LDKDecodeError err_var = (*val->contents.err);
1318         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1319         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1320         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1321         return err_ref;
1322 }
1323 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1324         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1325 }
1326 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1327         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1328         CHECK(val->result_ok);
1329         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1330         return res_ref;
1331 }
1332 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1333         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1334         CHECK(!val->result_ok);
1335         LDKDecodeError err_var = (*val->contents.err);
1336         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1337         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1338         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1339         return err_ref;
1340 }
1341 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1342         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1343         LDKSignature a_ref;
1344         CHECK(*((uint32_t*)a) == 64);
1345         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1346         ret->a = a_ref;
1347         LDKCVec_SignatureZ b_constr;
1348         b_constr.datalen = *((uint32_t*)b);
1349         if (b_constr.datalen > 0)
1350                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1351         else
1352                 b_constr.data = NULL;
1353         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1354         for (size_t m = 0; m < b_constr.datalen; m++) {
1355                 int8_tArray b_conv_12 = b_vals[m];
1356                 LDKSignature b_conv_12_ref;
1357                 CHECK(*((uint32_t*)b_conv_12) == 64);
1358                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1359                 b_constr.data[m] = b_conv_12_ref;
1360         }
1361         ret->b = b_constr;
1362         return (uint64_t)ret;
1363 }
1364 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1365         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1366         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1367         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1368         return a_arr;
1369 }
1370 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1371         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1372         LDKCVec_SignatureZ b_var = tuple->b;
1373         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1374         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1375         for (size_t m = 0; m < b_var.datalen; m++) {
1376                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1377                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1378                 b_arr_ptr[m] = b_conv_12_arr;
1379         }
1380         return b_arr;
1381 }
1382 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1383         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1384 }
1385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1386         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1387         CHECK(val->result_ok);
1388         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
1389         return res_ref;
1390 }
1391 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1392         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1393         CHECK(!val->result_ok);
1394         return *val->contents.err;
1395 }
1396 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1397         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1398 }
1399 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1400         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1401         CHECK(val->result_ok);
1402         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1403         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1404         return res_arr;
1405 }
1406 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1407         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1408         CHECK(!val->result_ok);
1409         return *val->contents.err;
1410 }
1411 typedef struct LDKBaseSign_JCalls {
1412         atomic_size_t refcnt;
1413         uint32_t get_per_commitment_point_meth;
1414         uint32_t release_commitment_secret_meth;
1415         uint32_t channel_keys_id_meth;
1416         uint32_t sign_counterparty_commitment_meth;
1417         uint32_t sign_holder_commitment_and_htlcs_meth;
1418         uint32_t sign_justice_revoked_output_meth;
1419         uint32_t sign_justice_revoked_htlc_meth;
1420         uint32_t sign_counterparty_htlc_transaction_meth;
1421         uint32_t sign_closing_transaction_meth;
1422         uint32_t sign_channel_announcement_meth;
1423         uint32_t ready_channel_meth;
1424 } LDKBaseSign_JCalls;
1425 static void LDKBaseSign_JCalls_free(void* this_arg) {
1426         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1427         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1428                 js_free(j_calls->get_per_commitment_point_meth);
1429                 js_free(j_calls->release_commitment_secret_meth);
1430                 js_free(j_calls->channel_keys_id_meth);
1431                 js_free(j_calls->sign_counterparty_commitment_meth);
1432                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1433                 js_free(j_calls->sign_justice_revoked_output_meth);
1434                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1435                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1436                 js_free(j_calls->sign_closing_transaction_meth);
1437                 js_free(j_calls->sign_channel_announcement_meth);
1438                 js_free(j_calls->ready_channel_meth);
1439                 FREE(j_calls);
1440         }
1441 }
1442 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1443         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1444         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1445         LDKPublicKey ret_ref;
1446         CHECK(*((uint32_t*)ret) == 33);
1447         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1448         return ret_ref;
1449 }
1450 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1451         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1452         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1453         LDKThirtyTwoBytes ret_ref;
1454         CHECK(*((uint32_t*)ret) == 32);
1455         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1456         return ret_ref;
1457 }
1458 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1459         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1460         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1461         LDKThirtyTwoBytes ret_ref;
1462         CHECK(*((uint32_t*)ret) == 32);
1463         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1464         return ret_ref;
1465 }
1466 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1467         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1468         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1469         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1470         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1471         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1472         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1473         if (commitment_tx_var.is_owned) {
1474                 commitment_tx_ref |= 1;
1475         }
1476         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1477         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1478         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1479         return ret_conv;
1480 }
1481 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1482         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1483         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1484         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1485         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1486         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1487         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1488         if (commitment_tx_var.is_owned) {
1489                 commitment_tx_ref |= 1;
1490         }
1491         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1492         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1493         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1494         return ret_conv;
1495 }
1496 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]) {
1497         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1498         LDKTransaction justice_tx_var = justice_tx;
1499         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1500         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1501         Transaction_free(justice_tx_var);
1502         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1503         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1504         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);
1505         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1506         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1507         return ret_conv;
1508 }
1509 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) {
1510         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1511         LDKTransaction justice_tx_var = justice_tx;
1512         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1513         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1514         Transaction_free(justice_tx_var);
1515         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1516         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1517         LDKHTLCOutputInCommitment htlc_var = *htlc;
1518         htlc_var = HTLCOutputInCommitment_clone(htlc);
1519         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1520         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1521         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1522         if (htlc_var.is_owned) {
1523                 htlc_ref |= 1;
1524         }
1525         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);
1526         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1527         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1528         return ret_conv;
1529 }
1530 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) {
1531         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1532         LDKTransaction htlc_tx_var = htlc_tx;
1533         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1534         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1535         Transaction_free(htlc_tx_var);
1536         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1537         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1538         LDKHTLCOutputInCommitment htlc_var = *htlc;
1539         htlc_var = HTLCOutputInCommitment_clone(htlc);
1540         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1541         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1542         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1543         if (htlc_var.is_owned) {
1544                 htlc_ref |= 1;
1545         }
1546         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);
1547         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1548         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1549         return ret_conv;
1550 }
1551 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
1552         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1553         LDKTransaction closing_tx_var = closing_tx;
1554         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1555         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1556         Transaction_free(closing_tx_var);
1557         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
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_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1563         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1564         LDKUnsignedChannelAnnouncement msg_var = *msg;
1565         msg_var = UnsignedChannelAnnouncement_clone(msg);
1566         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1567         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1568         uint64_t msg_ref = (uint64_t)msg_var.inner;
1569         if (msg_var.is_owned) {
1570                 msg_ref |= 1;
1571         }
1572         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1573         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1574         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1575         return ret_conv;
1576 }
1577 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1578         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1579         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1580         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1581         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1582         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1583         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1584         if (channel_parameters_var.is_owned) {
1585                 channel_parameters_ref |= 1;
1586         }
1587         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1588 }
1589 static void* LDKBaseSign_JCalls_clone(const void* this_arg) {
1590         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1591         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1592         return (void*) this_arg;
1593 }
1594 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1595         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1596         atomic_init(&calls->refcnt, 1);
1597         //TODO: Assign calls->o from o
1598
1599         LDKChannelPublicKeys pubkeys_conv;
1600         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1601         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1602         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1603
1604         LDKBaseSign ret = {
1605                 .this_arg = (void*) calls,
1606                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1607                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1608                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1609                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1610                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1611                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1612                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1613                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1614                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1615                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1616                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1617                 .free = LDKBaseSign_JCalls_free,
1618                 .pubkeys = pubkeys_conv,
1619                 .set_pubkeys = NULL,
1620         };
1621         return ret;
1622 }
1623 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1624         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1625         *res_ptr = LDKBaseSign_init(o, pubkeys);
1626         return (long)res_ptr;
1627 }
1628 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1629         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1630         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1631         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1632         return ret_arr;
1633 }
1634
1635 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1636         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1637         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1638         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1639         return ret_arr;
1640 }
1641
1642 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1643         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1644         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1645         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1646         return ret_arr;
1647 }
1648
1649 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1650         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1651         LDKCommitmentTransaction commitment_tx_conv;
1652         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1653         commitment_tx_conv.is_owned = false;
1654         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1655         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1656         return (uint64_t)ret_conv;
1657 }
1658
1659 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1660         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1661         LDKHolderCommitmentTransaction commitment_tx_conv;
1662         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1663         commitment_tx_conv.is_owned = false;
1664         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1665         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1666         return (uint64_t)ret_conv;
1667 }
1668
1669 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) {
1670         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1671         LDKTransaction justice_tx_ref;
1672         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1673         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1674         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1675         justice_tx_ref.data_is_owned = true;
1676         unsigned char per_commitment_key_arr[32];
1677         CHECK(*((uint32_t*)per_commitment_key) == 32);
1678         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1679         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1680         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1681         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1682         return (uint64_t)ret_conv;
1683 }
1684
1685 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) {
1686         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1687         LDKTransaction justice_tx_ref;
1688         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1689         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1690         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1691         justice_tx_ref.data_is_owned = true;
1692         unsigned char per_commitment_key_arr[32];
1693         CHECK(*((uint32_t*)per_commitment_key) == 32);
1694         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1695         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1696         LDKHTLCOutputInCommitment htlc_conv;
1697         htlc_conv.inner = (void*)(htlc & (~1));
1698         htlc_conv.is_owned = false;
1699         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1700         *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);
1701         return (uint64_t)ret_conv;
1702 }
1703
1704 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) {
1705         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1706         LDKTransaction htlc_tx_ref;
1707         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1708         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1709         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1710         htlc_tx_ref.data_is_owned = true;
1711         LDKPublicKey per_commitment_point_ref;
1712         CHECK(*((uint32_t*)per_commitment_point) == 33);
1713         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1714         LDKHTLCOutputInCommitment htlc_conv;
1715         htlc_conv.inner = (void*)(htlc & (~1));
1716         htlc_conv.is_owned = false;
1717         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1718         *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);
1719         return (uint64_t)ret_conv;
1720 }
1721
1722 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1723         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1724         LDKTransaction closing_tx_ref;
1725         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1726         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1727         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1728         closing_tx_ref.data_is_owned = true;
1729         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1730         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1731         return (uint64_t)ret_conv;
1732 }
1733
1734 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1735         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1736         LDKUnsignedChannelAnnouncement msg_conv;
1737         msg_conv.inner = (void*)(msg & (~1));
1738         msg_conv.is_owned = false;
1739         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1740         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1741         return (uint64_t)ret_conv;
1742 }
1743
1744 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1745         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1746         LDKChannelTransactionParameters channel_parameters_conv;
1747         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1748         channel_parameters_conv.is_owned = false;
1749         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1750 }
1751
1752 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1753         if (this_arg->set_pubkeys != NULL)
1754                 this_arg->set_pubkeys(this_arg);
1755         return this_arg->pubkeys;
1756 }
1757 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1758         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1759         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1760         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1761         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1762         uint64_t ret_ref = (uint64_t)ret_var.inner;
1763         if (ret_var.is_owned) {
1764                 ret_ref |= 1;
1765         }
1766         return ret_ref;
1767 }
1768
1769 typedef struct LDKSign_JCalls {
1770         atomic_size_t refcnt;
1771         LDKBaseSign_JCalls* BaseSign;
1772         uint32_t write_meth;
1773 } LDKSign_JCalls;
1774 static void LDKSign_JCalls_free(void* this_arg) {
1775         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1776         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1777                 js_free(j_calls->write_meth);
1778                 FREE(j_calls);
1779         }
1780 }
1781 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1782         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1783         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1784         LDKCVec_u8Z ret_ref;
1785         ret_ref.datalen = *((uint32_t*)ret);
1786         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1787         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1788         return ret_ref;
1789 }
1790 static void* LDKSign_JCalls_clone(const void* this_arg) {
1791         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1792         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1793         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1794         return (void*) this_arg;
1795 }
1796 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1797         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1798         atomic_init(&calls->refcnt, 1);
1799         //TODO: Assign calls->o from o
1800
1801         LDKChannelPublicKeys pubkeys_conv;
1802         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1803         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1804         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1805
1806         LDKSign ret = {
1807                 .this_arg = (void*) calls,
1808                 .write = write_LDKSign_jcall,
1809                 .clone = LDKSign_JCalls_clone,
1810                 .free = LDKSign_JCalls_free,
1811                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1812         };
1813         calls->BaseSign = ret.BaseSign.this_arg;
1814         return ret;
1815 }
1816 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
1817         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1818         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
1819         return (long)res_ptr;
1820 }
1821 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
1822         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1823         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1824         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1825         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
1826         CVec_u8Z_free(ret_var);
1827         return ret_arr;
1828 }
1829
1830 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
1831         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
1832 }
1833 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
1834         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1835         CHECK(val->result_ok);
1836         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
1837         *ret = Sign_clone(&(*val->contents.result));
1838         return (uint64_t)ret;
1839 }
1840 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
1841         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
1842         CHECK(!val->result_ok);
1843         LDKDecodeError err_var = (*val->contents.err);
1844         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1845         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1846         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1847         return err_ref;
1848 }
1849 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
1850         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
1851 }
1852 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
1853         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1854         CHECK(val->result_ok);
1855         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
1856         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
1857         return es_arr;
1858 }
1859 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
1860         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
1861         CHECK(!val->result_ok);
1862         return *val->contents.err;
1863 }
1864 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
1865         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
1866         for (size_t i = 0; i < ret.datalen; i++) {
1867                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
1868         }
1869         return ret;
1870 }
1871 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
1872         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
1873 }
1874 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
1875         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1876         CHECK(val->result_ok);
1877         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
1878         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1879         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1880         for (size_t m = 0; m < res_var.datalen; m++) {
1881                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
1882                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1883                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
1884                 res_arr_ptr[m] = res_conv_12_arr;
1885         }
1886         return res_arr;
1887 }
1888 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
1889         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
1890         CHECK(!val->result_ok);
1891         return *val->contents.err;
1892 }
1893 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
1894         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
1895 }
1896 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
1897         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1898         CHECK(val->result_ok);
1899         LDKInMemorySigner res_var = (*val->contents.result);
1900         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1901         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1902         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1903         return res_ref;
1904 }
1905 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
1906         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
1907         CHECK(!val->result_ok);
1908         LDKDecodeError err_var = (*val->contents.err);
1909         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1910         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1911         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1912         return err_ref;
1913 }
1914 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
1915         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
1916         ret->datalen = *((uint32_t*)elems);
1917         if (ret->datalen == 0) {
1918                 ret->data = NULL;
1919         } else {
1920                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
1921                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1922                 for (size_t i = 0; i < ret->datalen; i++) {
1923                         uint32_t arr_elem = java_elems[i];
1924                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
1925                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
1926                         ret->data[i] = arr_elem_conv;
1927                 }
1928         }
1929         return (uint64_t)ret;
1930 }
1931 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1932         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1933         for (size_t i = 0; i < ret.datalen; i++) {
1934                 ret.data[i] = TxOut_clone(&orig->data[i]);
1935         }
1936         return ret;
1937 }
1938 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
1939         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
1940 }
1941 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
1942         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1943         CHECK(val->result_ok);
1944         LDKTransaction res_var = (*val->contents.result);
1945         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1946         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
1947         return res_arr;
1948 }
1949 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
1950         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
1951         CHECK(!val->result_ok);
1952         return *val->contents.err;
1953 }
1954 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1955         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1956         LDKThirtyTwoBytes a_ref;
1957         CHECK(*((uint32_t*)a) == 32);
1958         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1959         ret->a = a_ref;
1960         LDKChannelMonitor b_conv;
1961         b_conv.inner = (void*)(b & (~1));
1962         b_conv.is_owned = (b & 1) || (b == 0);
1963         b_conv = ChannelMonitor_clone(&b_conv);
1964         ret->b = b_conv;
1965         return (uint64_t)ret;
1966 }
1967 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1968         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1969         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1970         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1971         return a_arr;
1972 }
1973 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1974         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1975         LDKChannelMonitor b_var = tuple->b;
1976         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1977         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1978         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
1979         return b_ref;
1980 }
1981 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
1982         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
1983         ret->datalen = *((uint32_t*)elems);
1984         if (ret->datalen == 0) {
1985                 ret->data = NULL;
1986         } else {
1987                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
1988                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1989                 for (size_t i = 0; i < ret->datalen; i++) {
1990                         uint32_t arr_elem = java_elems[i];
1991                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
1992                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
1993                         ret->data[i] = arr_elem_conv;
1994                 }
1995         }
1996         return (uint64_t)ret;
1997 }
1998 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
1999         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2000 }
2001 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2002         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2003         CHECK(val->result_ok);
2004         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2005         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2006         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2007         for (size_t m = 0; m < res_var.datalen; m++) {
2008                 uint64_t res_conv_38_ref = (uint64_t)(&res_var.data[m]) | 1;
2009                 res_arr_ptr[m] = res_conv_38_ref;
2010         }
2011         return res_arr;
2012 }
2013 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2014         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2015         CHECK(!val->result_ok);
2016         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2017         return err_conv;
2018 }
2019 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2020         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2021         switch(obj->tag) {
2022                 case LDKAPIError_APIMisuseError: {
2023                         LDKStr err_str = obj->api_misuse_error.err;
2024                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2025                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2026                 }
2027                 case LDKAPIError_FeeRateTooHigh: {
2028                         LDKStr err_str = obj->fee_rate_too_high.err;
2029                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2030                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2031                 }
2032                 case LDKAPIError_RouteError: {
2033                         LDKStr err_str = obj->route_error.err;
2034                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2035                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2036                 }
2037                 case LDKAPIError_ChannelUnavailable: {
2038                         LDKStr err_str = obj->channel_unavailable.err;
2039                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2040                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2041                 }
2042                 case LDKAPIError_MonitorUpdateFailed: {
2043                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2044                 }
2045                 default: abort();
2046         }
2047 }
2048 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2049         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2050 }
2051 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2052         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2053         CHECK(val->result_ok);
2054         return *val->contents.result;
2055 }
2056 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2057         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2058         CHECK(!val->result_ok);
2059         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2060         return err_ref;
2061 }
2062 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2063         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2064         ret->datalen = *((uint32_t*)elems);
2065         if (ret->datalen == 0) {
2066                 ret->data = NULL;
2067         } else {
2068                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2069                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2070                 for (size_t i = 0; i < ret->datalen; i++) {
2071                         uint32_t arr_elem = java_elems[i];
2072                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2073                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2074                         ret->data[i] = arr_elem_conv;
2075                 }
2076         }
2077         return (uint64_t)ret;
2078 }
2079 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2080         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2081         for (size_t i = 0; i < ret.datalen; i++) {
2082                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2083         }
2084         return ret;
2085 }
2086 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2087         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2088         ret->datalen = *((uint32_t*)elems);
2089         if (ret->datalen == 0) {
2090                 ret->data = NULL;
2091         } else {
2092                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2093                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2094                 for (size_t i = 0; i < ret->datalen; i++) {
2095                         uint32_t arr_elem = java_elems[i];
2096                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2097                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2098                         ret->data[i] = arr_elem_conv;
2099                 }
2100         }
2101         return (uint64_t)ret;
2102 }
2103 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2104         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2105         for (size_t i = 0; i < ret.datalen; i++) {
2106                 ret.data[i] = APIError_clone(&orig->data[i]);
2107         }
2108         return ret;
2109 }
2110 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2111         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2112         switch(obj->tag) {
2113                 case LDKPaymentSendFailure_ParameterError: {
2114                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2115                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2116                 }
2117                 case LDKPaymentSendFailure_PathParameterError: {
2118                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2119                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2120                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2121                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2122                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2123                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2124                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2125                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2126                         }
2127                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2128                 }
2129                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2130                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2131                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2132                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2133                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2134                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2135                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2136                         }
2137                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2138                 }
2139                 case LDKPaymentSendFailure_PartialFailure: {
2140                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2141                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2142                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2143                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2144                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2145                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2146                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2147                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2148                         }
2149                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2150                 }
2151                 default: abort();
2152         }
2153 }
2154 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2155         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2156 }
2157 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2158         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2159         CHECK(val->result_ok);
2160         return *val->contents.result;
2161 }
2162 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2163         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2164         CHECK(!val->result_ok);
2165         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2166         return err_ref;
2167 }
2168 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2169         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2170         switch(obj->tag) {
2171                 case LDKNetAddress_IPv4: {
2172                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2173                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2174                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2175                 }
2176                 case LDKNetAddress_IPv6: {
2177                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2178                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2179                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2180                 }
2181                 case LDKNetAddress_OnionV2: {
2182                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2183                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2184                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2185                 }
2186                 case LDKNetAddress_OnionV3: {
2187                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2188                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2189                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2190                 }
2191                 default: abort();
2192         }
2193 }
2194 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2195         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2196         ret->datalen = *((uint32_t*)elems);
2197         if (ret->datalen == 0) {
2198                 ret->data = NULL;
2199         } else {
2200                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2201                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2202                 for (size_t i = 0; i < ret->datalen; i++) {
2203                         uint32_t arr_elem = java_elems[i];
2204                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2205                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2206                         ret->data[i] = arr_elem_conv;
2207                 }
2208         }
2209         return (uint64_t)ret;
2210 }
2211 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2212         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2213         for (size_t i = 0; i < ret.datalen; i++) {
2214                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2215         }
2216         return ret;
2217 }
2218 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2219         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2220         LDKThirtyTwoBytes a_ref;
2221         CHECK(*((uint32_t*)a) == 32);
2222         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2223         ret->a = a_ref;
2224         LDKThirtyTwoBytes b_ref;
2225         CHECK(*((uint32_t*)b) == 32);
2226         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2227         ret->b = b_ref;
2228         return (uint64_t)ret;
2229 }
2230 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t ptr) {
2231         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2232         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2233         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2234         return a_arr;
2235 }
2236 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t ptr) {
2237         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
2238         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2239         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2240         return b_arr;
2241 }
2242 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2243         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2244 }
2245 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2246         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2247         CHECK(val->result_ok);
2248         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2249         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2250         return res_arr;
2251 }
2252 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2253         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2254         CHECK(!val->result_ok);
2255         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2256         return err_ref;
2257 }
2258 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2259         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2260         ret->datalen = *((uint32_t*)elems);
2261         if (ret->datalen == 0) {
2262                 ret->data = NULL;
2263         } else {
2264                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2265                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2266                 for (size_t i = 0; i < ret->datalen; i++) {
2267                         uint32_t arr_elem = java_elems[i];
2268                         LDKChannelMonitor arr_elem_conv;
2269                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2270                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2271                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2272                         ret->data[i] = arr_elem_conv;
2273                 }
2274         }
2275         return (uint64_t)ret;
2276 }
2277 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2278         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2279         for (size_t i = 0; i < ret.datalen; i++) {
2280                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2281         }
2282         return ret;
2283 }
2284 typedef struct LDKWatch_JCalls {
2285         atomic_size_t refcnt;
2286         uint32_t watch_channel_meth;
2287         uint32_t update_channel_meth;
2288         uint32_t release_pending_monitor_events_meth;
2289 } LDKWatch_JCalls;
2290 static void LDKWatch_JCalls_free(void* this_arg) {
2291         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2292         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2293                 js_free(j_calls->watch_channel_meth);
2294                 js_free(j_calls->update_channel_meth);
2295                 js_free(j_calls->release_pending_monitor_events_meth);
2296                 FREE(j_calls);
2297         }
2298 }
2299 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2300         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2301         LDKOutPoint funding_txo_var = funding_txo;
2302         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2303         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2304         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2305         if (funding_txo_var.is_owned) {
2306                 funding_txo_ref |= 1;
2307         }
2308         LDKChannelMonitor monitor_var = monitor;
2309         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2310         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2311         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2312         if (monitor_var.is_owned) {
2313                 monitor_ref |= 1;
2314         }
2315         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2316         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2317         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2318         return ret_conv;
2319 }
2320 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2321         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2322         LDKOutPoint funding_txo_var = funding_txo;
2323         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2324         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2325         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2326         if (funding_txo_var.is_owned) {
2327                 funding_txo_ref |= 1;
2328         }
2329         LDKChannelMonitorUpdate update_var = update;
2330         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2331         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2332         uint64_t update_ref = (uint64_t)update_var.inner;
2333         if (update_var.is_owned) {
2334                 update_ref |= 1;
2335         }
2336         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2337         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2338         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2339         return ret_conv;
2340 }
2341 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2342         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2343         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2344         LDKCVec_MonitorEventZ ret_constr;
2345         ret_constr.datalen = *((uint32_t*)ret);
2346         if (ret_constr.datalen > 0)
2347                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2348         else
2349                 ret_constr.data = NULL;
2350         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2351         for (size_t o = 0; o < ret_constr.datalen; o++) {
2352                 uint32_t ret_conv_14 = ret_vals[o];
2353                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2354                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2355                 ret_constr.data[o] = ret_conv_14_conv;
2356         }
2357         return ret_constr;
2358 }
2359 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2360         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2362         return (void*) this_arg;
2363 }
2364 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2365         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2366         atomic_init(&calls->refcnt, 1);
2367         //TODO: Assign calls->o from o
2368
2369         LDKWatch ret = {
2370                 .this_arg = (void*) calls,
2371                 .watch_channel = watch_channel_LDKWatch_jcall,
2372                 .update_channel = update_channel_LDKWatch_jcall,
2373                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2374                 .free = LDKWatch_JCalls_free,
2375         };
2376         return ret;
2377 }
2378 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2379         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2380         *res_ptr = LDKWatch_init(o);
2381         return (long)res_ptr;
2382 }
2383 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2384         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2385         LDKOutPoint funding_txo_conv;
2386         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2387         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2388         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2389         LDKChannelMonitor monitor_conv;
2390         monitor_conv.inner = (void*)(monitor & (~1));
2391         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2392         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2393         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2394         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2395         return (uint64_t)ret_conv;
2396 }
2397
2398 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2399         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2400         LDKOutPoint funding_txo_conv;
2401         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2402         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2403         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2404         LDKChannelMonitorUpdate update_conv;
2405         update_conv.inner = (void*)(update & (~1));
2406         update_conv.is_owned = (update & 1) || (update == 0);
2407         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2408         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2409         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2410         return (uint64_t)ret_conv;
2411 }
2412
2413 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2414         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2415         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2416         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2417         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2418         for (size_t o = 0; o < ret_var.datalen; o++) {
2419                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2420                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2421                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2422                 ret_arr_ptr[o] = ret_conv_14_ref;
2423         }
2424         FREE(ret_var.data);
2425         return ret_arr;
2426 }
2427
2428 typedef struct LDKBroadcasterInterface_JCalls {
2429         atomic_size_t refcnt;
2430         uint32_t broadcast_transaction_meth;
2431 } LDKBroadcasterInterface_JCalls;
2432 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2433         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2434         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2435                 js_free(j_calls->broadcast_transaction_meth);
2436                 FREE(j_calls);
2437         }
2438 }
2439 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2440         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2441         LDKTransaction tx_var = tx;
2442         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2443         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2444         Transaction_free(tx_var);
2445         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2446 }
2447 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2448         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2449         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2450         return (void*) this_arg;
2451 }
2452 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2453         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2454         atomic_init(&calls->refcnt, 1);
2455         //TODO: Assign calls->o from o
2456
2457         LDKBroadcasterInterface ret = {
2458                 .this_arg = (void*) calls,
2459                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2460                 .free = LDKBroadcasterInterface_JCalls_free,
2461         };
2462         return ret;
2463 }
2464 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2465         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2466         *res_ptr = LDKBroadcasterInterface_init(o);
2467         return (long)res_ptr;
2468 }
2469 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2470         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2471         LDKTransaction tx_ref;
2472         tx_ref.datalen = *((uint32_t*)tx);
2473         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2474         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2475         tx_ref.data_is_owned = true;
2476         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2477 }
2478
2479 typedef struct LDKKeysInterface_JCalls {
2480         atomic_size_t refcnt;
2481         uint32_t get_node_secret_meth;
2482         uint32_t get_destination_script_meth;
2483         uint32_t get_shutdown_pubkey_meth;
2484         uint32_t get_channel_signer_meth;
2485         uint32_t get_secure_random_bytes_meth;
2486         uint32_t read_chan_signer_meth;
2487         uint32_t sign_invoice_meth;
2488 } LDKKeysInterface_JCalls;
2489 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2490         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2491         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2492                 js_free(j_calls->get_node_secret_meth);
2493                 js_free(j_calls->get_destination_script_meth);
2494                 js_free(j_calls->get_shutdown_pubkey_meth);
2495                 js_free(j_calls->get_channel_signer_meth);
2496                 js_free(j_calls->get_secure_random_bytes_meth);
2497                 js_free(j_calls->read_chan_signer_meth);
2498                 js_free(j_calls->sign_invoice_meth);
2499                 FREE(j_calls);
2500         }
2501 }
2502 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2503         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2504         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2505         LDKSecretKey ret_ref;
2506         CHECK(*((uint32_t*)ret) == 32);
2507         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2508         return ret_ref;
2509 }
2510 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2511         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2512         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2513         LDKCVec_u8Z ret_ref;
2514         ret_ref.datalen = *((uint32_t*)ret);
2515         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2516         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2517         return ret_ref;
2518 }
2519 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
2520         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2521         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2522         LDKPublicKey ret_ref;
2523         CHECK(*((uint32_t*)ret) == 33);
2524         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2525         return ret_ref;
2526 }
2527 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2528         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2529         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2530         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2531         ret_conv = Sign_clone(ret);
2532         return ret_conv;
2533 }
2534 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2535         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2536         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2537         LDKThirtyTwoBytes ret_ref;
2538         CHECK(*((uint32_t*)ret) == 32);
2539         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2540         return ret_ref;
2541 }
2542 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2543         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2544         LDKu8slice reader_var = reader;
2545         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2546         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2547         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2548         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2549         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2550         return ret_conv;
2551 }
2552 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2553         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2554         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2555         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2556         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2557         CVec_u8Z_free(invoice_preimage_var);
2558         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2559         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2560         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2561         return ret_conv;
2562 }
2563 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2564         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2565         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2566         return (void*) this_arg;
2567 }
2568 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2569         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2570         atomic_init(&calls->refcnt, 1);
2571         //TODO: Assign calls->o from o
2572
2573         LDKKeysInterface ret = {
2574                 .this_arg = (void*) calls,
2575                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2576                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2577                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
2578                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2579                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2580                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2581                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2582                 .free = LDKKeysInterface_JCalls_free,
2583         };
2584         return ret;
2585 }
2586 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2587         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2588         *res_ptr = LDKKeysInterface_init(o);
2589         return (long)res_ptr;
2590 }
2591 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2592         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2593         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2594         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2595         return ret_arr;
2596 }
2597
2598 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2599         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2600         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2601         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2602         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2603         CVec_u8Z_free(ret_var);
2604         return ret_arr;
2605 }
2606
2607 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2608         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2609         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2610         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2611         return ret_arr;
2612 }
2613
2614 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2615         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2616         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2617         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2618         return (uint64_t)ret;
2619 }
2620
2621 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2622         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2623         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2624         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2625         return ret_arr;
2626 }
2627
2628 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2629         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2630         LDKu8slice reader_ref;
2631         reader_ref.datalen = *((uint32_t*)reader);
2632         reader_ref.data = (int8_t*)(reader + 4);
2633         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2634         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2635         return (uint64_t)ret_conv;
2636 }
2637
2638 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2639         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2640         LDKCVec_u8Z invoice_preimage_ref;
2641         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2642         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2643         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2644         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2645         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2646         return (uint64_t)ret_conv;
2647 }
2648
2649 typedef struct LDKFeeEstimator_JCalls {
2650         atomic_size_t refcnt;
2651         uint32_t get_est_sat_per_1000_weight_meth;
2652 } LDKFeeEstimator_JCalls;
2653 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2654         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2655         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2656                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2657                 FREE(j_calls);
2658         }
2659 }
2660 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2661         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2662         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2663         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2664 }
2665 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2666         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2667         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2668         return (void*) this_arg;
2669 }
2670 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2671         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2672         atomic_init(&calls->refcnt, 1);
2673         //TODO: Assign calls->o from o
2674
2675         LDKFeeEstimator ret = {
2676                 .this_arg = (void*) calls,
2677                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2678                 .free = LDKFeeEstimator_JCalls_free,
2679         };
2680         return ret;
2681 }
2682 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2683         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2684         *res_ptr = LDKFeeEstimator_init(o);
2685         return (long)res_ptr;
2686 }
2687 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2688         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2689         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2690         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2691         return ret_val;
2692 }
2693
2694 typedef struct LDKLogger_JCalls {
2695         atomic_size_t refcnt;
2696         uint32_t log_meth;
2697 } LDKLogger_JCalls;
2698 static void LDKLogger_JCalls_free(void* this_arg) {
2699         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2700         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2701                 js_free(j_calls->log_meth);
2702                 FREE(j_calls);
2703         }
2704 }
2705 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2706         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2707         const char* record_str = record;
2708         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2709         js_invoke_function_1(j_calls->log_meth, record_conv);
2710 }
2711 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2712         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2713         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2714         return (void*) this_arg;
2715 }
2716 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2717         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2718         atomic_init(&calls->refcnt, 1);
2719         //TODO: Assign calls->o from o
2720
2721         LDKLogger ret = {
2722                 .this_arg = (void*) calls,
2723                 .log = log_LDKLogger_jcall,
2724                 .free = LDKLogger_JCalls_free,
2725         };
2726         return ret;
2727 }
2728 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2729         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2730         *res_ptr = LDKLogger_init(o);
2731         return (long)res_ptr;
2732 }
2733 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2734         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2735         LDKThirtyTwoBytes a_ref;
2736         CHECK(*((uint32_t*)a) == 32);
2737         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2738         ret->a = a_ref;
2739         LDKChannelManager b_conv;
2740         b_conv.inner = (void*)(b & (~1));
2741         b_conv.is_owned = (b & 1) || (b == 0);
2742         // Warning: we need a move here but no clone is available for LDKChannelManager
2743         ret->b = b_conv;
2744         return (uint64_t)ret;
2745 }
2746 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2747         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2748         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2749         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2750         return a_arr;
2751 }
2752 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2753         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2754         LDKChannelManager b_var = tuple->b;
2755         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2756         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2757         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2758         return b_ref;
2759 }
2760 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2761         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2762 }
2763 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2764         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2765         CHECK(val->result_ok);
2766         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2767         return res_ref;
2768 }
2769 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2770         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2771         CHECK(!val->result_ok);
2772         LDKDecodeError err_var = (*val->contents.err);
2773         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2774         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2775         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2776         return err_ref;
2777 }
2778 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
2779         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
2780 }
2781 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
2782         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2783         CHECK(val->result_ok);
2784         LDKChannelConfig res_var = (*val->contents.result);
2785         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2786         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2787         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2788         return res_ref;
2789 }
2790 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
2791         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
2792         CHECK(!val->result_ok);
2793         LDKDecodeError err_var = (*val->contents.err);
2794         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2795         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2796         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2797         return err_ref;
2798 }
2799 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
2800         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
2801 }
2802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
2803         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2804         CHECK(val->result_ok);
2805         LDKOutPoint res_var = (*val->contents.result);
2806         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2807         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2808         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2809         return res_ref;
2810 }
2811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
2812         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
2813         CHECK(!val->result_ok);
2814         LDKDecodeError err_var = (*val->contents.err);
2815         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2816         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2817         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2818         return err_ref;
2819 }
2820 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
2821         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
2822 }
2823 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
2824         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2825         CHECK(val->result_ok);
2826         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
2827         return res_conv;
2828 }
2829 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
2830         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
2831         CHECK(!val->result_ok);
2832         return *val->contents.err;
2833 }
2834 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
2835         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
2836 }
2837 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
2838         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2839         CHECK(val->result_ok);
2840         LDKInvoice res_var = (*val->contents.result);
2841         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2842         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2843         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2844         return res_ref;
2845 }
2846 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
2847         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
2848         CHECK(!val->result_ok);
2849         return *val->contents.err;
2850 }
2851 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
2852         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
2853 }
2854 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
2855         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2856         CHECK(val->result_ok);
2857         LDKSignedRawInvoice res_var = (*val->contents.result);
2858         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2859         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2860         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2861         return res_ref;
2862 }
2863 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
2864         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
2865         CHECK(!val->result_ok);
2866         return *val->contents.err;
2867 }
2868 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
2869         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
2870         LDKRawInvoice a_conv;
2871         a_conv.inner = (void*)(a & (~1));
2872         a_conv.is_owned = (a & 1) || (a == 0);
2873         a_conv = RawInvoice_clone(&a_conv);
2874         ret->a = a_conv;
2875         LDKThirtyTwoBytes b_ref;
2876         CHECK(*((uint32_t*)b) == 32);
2877         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2878         ret->b = b_ref;
2879         LDKInvoiceSignature c_conv;
2880         c_conv.inner = (void*)(c & (~1));
2881         c_conv.is_owned = (c & 1) || (c == 0);
2882         c_conv = InvoiceSignature_clone(&c_conv);
2883         ret->c = c_conv;
2884         return (uint64_t)ret;
2885 }
2886 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t ptr) {
2887         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2888         LDKRawInvoice a_var = tuple->a;
2889         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2890         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2891         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
2892         return a_ref;
2893 }
2894 int8_tArray  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t ptr) {
2895         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2896         int8_tArray b_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2897         memcpy((uint8_t*)(b_arr + 4), tuple->b.data, 32);
2898         return b_arr;
2899 }
2900 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t ptr) {
2901         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
2902         LDKInvoiceSignature c_var = tuple->c;
2903         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2904         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2905         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
2906         return c_ref;
2907 }
2908 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
2909         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
2910 }
2911 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
2912         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2913         CHECK(val->result_ok);
2914         LDKPayeePubKey res_var = (*val->contents.result);
2915         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2916         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2917         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2918         return res_ref;
2919 }
2920 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
2921         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
2922         CHECK(!val->result_ok);
2923         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2924         return err_conv;
2925 }
2926 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
2927         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
2928         ret->datalen = *((uint32_t*)elems);
2929         if (ret->datalen == 0) {
2930                 ret->data = NULL;
2931         } else {
2932                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
2933                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2934                 for (size_t i = 0; i < ret->datalen; i++) {
2935                         uint32_t arr_elem = java_elems[i];
2936                         LDKPrivateRoute arr_elem_conv;
2937                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2938                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2939                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
2940                         ret->data[i] = arr_elem_conv;
2941                 }
2942         }
2943         return (uint64_t)ret;
2944 }
2945 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
2946         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
2947         for (size_t i = 0; i < ret.datalen; i++) {
2948                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
2949         }
2950         return ret;
2951 }
2952 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
2953         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
2954 }
2955 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
2956         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2957         CHECK(val->result_ok);
2958         LDKPositiveTimestamp res_var = (*val->contents.result);
2959         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2960         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2961         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2962         return res_ref;
2963 }
2964 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
2965         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
2966         CHECK(!val->result_ok);
2967         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
2968         return err_conv;
2969 }
2970 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
2971         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
2972 }
2973 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
2974         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
2975         CHECK(val->result_ok);
2976         return *val->contents.result;
2977 }
2978 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
2979         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
2980         CHECK(!val->result_ok);
2981         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
2982         return err_conv;
2983 }
2984 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
2985         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
2986 }
2987 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
2988         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
2989         CHECK(val->result_ok);
2990         LDKInvoice res_var = (*val->contents.result);
2991         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2992         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2993         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2994         return res_ref;
2995 }
2996 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
2997         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
2998         CHECK(!val->result_ok);
2999         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3000         return err_conv;
3001 }
3002 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3003         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3004 }
3005 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3006         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3007         CHECK(val->result_ok);
3008         LDKDescription res_var = (*val->contents.result);
3009         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3010         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3011         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3012         return res_ref;
3013 }
3014 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3015         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3016         CHECK(!val->result_ok);
3017         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3018         return err_conv;
3019 }
3020 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3021         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3022 }
3023 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3024         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3025         CHECK(val->result_ok);
3026         LDKExpiryTime res_var = (*val->contents.result);
3027         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3028         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3029         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3030         return res_ref;
3031 }
3032 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3033         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3034         CHECK(!val->result_ok);
3035         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3036         return err_conv;
3037 }
3038 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3039         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3040 }
3041 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3042         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3043         CHECK(val->result_ok);
3044         LDKPrivateRoute res_var = (*val->contents.result);
3045         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3046         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3047         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3048         return res_ref;
3049 }
3050 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3051         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3052         CHECK(!val->result_ok);
3053         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3054         return err_conv;
3055 }
3056 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3057         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3058 }
3059 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3060         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3061         CHECK(val->result_ok);
3062         LDKStr res_str = (*val->contents.result);
3063         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3064         return res_conv;
3065 }
3066 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3067         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3068         CHECK(!val->result_ok);
3069         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3070         return err_conv;
3071 }
3072 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3073         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3074 }
3075 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3076         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3077         CHECK(val->result_ok);
3078         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3079         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3080         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3081         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3082         return res_ref;
3083 }
3084 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3085         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3086         CHECK(!val->result_ok);
3087         LDKDecodeError err_var = (*val->contents.err);
3088         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3089         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3090         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3091         return err_ref;
3092 }
3093 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3094         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3095 }
3096 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3097         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3098         CHECK(val->result_ok);
3099         LDKHTLCUpdate res_var = (*val->contents.result);
3100         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3101         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3102         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3103         return res_ref;
3104 }
3105 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3106         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3107         CHECK(!val->result_ok);
3108         LDKDecodeError err_var = (*val->contents.err);
3109         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3110         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3111         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3112         return err_ref;
3113 }
3114 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3115         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3116 }
3117 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3118         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3119         CHECK(val->result_ok);
3120         return *val->contents.result;
3121 }
3122 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3123         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3124         CHECK(!val->result_ok);
3125         LDKMonitorUpdateError err_var = (*val->contents.err);
3126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3128         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3129         return err_ref;
3130 }
3131 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3132         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3133         LDKOutPoint a_conv;
3134         a_conv.inner = (void*)(a & (~1));
3135         a_conv.is_owned = (a & 1) || (a == 0);
3136         a_conv = OutPoint_clone(&a_conv);
3137         ret->a = a_conv;
3138         LDKCVec_u8Z b_ref;
3139         b_ref.datalen = *((uint32_t*)b);
3140         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3141         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3142         ret->b = b_ref;
3143         return (uint64_t)ret;
3144 }
3145 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
3146         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3147         LDKOutPoint a_var = tuple->a;
3148         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3149         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3150         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3151         return a_ref;
3152 }
3153 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
3154         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
3155         LDKCVec_u8Z b_var = tuple->b;
3156         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3157         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3158         return b_arr;
3159 }
3160 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3161         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3162         ret->a = a;
3163         LDKCVec_u8Z b_ref;
3164         b_ref.datalen = *((uint32_t*)b);
3165         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3166         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3167         ret->b = b_ref;
3168         return (uint64_t)ret;
3169 }
3170 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
3171         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3172         return tuple->a;
3173 }
3174 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
3175         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
3176         LDKCVec_u8Z b_var = tuple->b;
3177         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3178         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
3179         return b_arr;
3180 }
3181 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3182         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3183         ret->datalen = *((uint32_t*)elems);
3184         if (ret->datalen == 0) {
3185                 ret->data = NULL;
3186         } else {
3187                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3188                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3189                 for (size_t i = 0; i < ret->datalen; i++) {
3190                         uint32_t arr_elem = java_elems[i];
3191                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3192                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3193                         ret->data[i] = arr_elem_conv;
3194                 }
3195         }
3196         return (uint64_t)ret;
3197 }
3198 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3199         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3200         for (size_t i = 0; i < ret.datalen; i++) {
3201                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3202         }
3203         return ret;
3204 }
3205 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3206         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3207         LDKThirtyTwoBytes a_ref;
3208         CHECK(*((uint32_t*)a) == 32);
3209         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3210         ret->a = a_ref;
3211         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3212         b_constr.datalen = *((uint32_t*)b);
3213         if (b_constr.datalen > 0)
3214                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3215         else
3216                 b_constr.data = NULL;
3217         uint32_t* b_vals = (uint32_t*)(b + 4);
3218         for (size_t e = 0; e < b_constr.datalen; e++) {
3219                 uint32_t b_conv_30 = b_vals[e];
3220                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
3221                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
3222                 b_constr.data[e] = b_conv_30_conv;
3223         }
3224         ret->b = b_constr;
3225         return (uint64_t)ret;
3226 }
3227 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
3228         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3229         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3230         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3231         return a_arr;
3232 }
3233 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
3234         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
3235         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
3236         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3237         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3238         for (size_t e = 0; e < b_var.datalen; e++) {
3239                 uint64_t b_conv_30_ref = (uint64_t)(&b_var.data[e]) | 1;
3240                 b_arr_ptr[e] = b_conv_30_ref;
3241         }
3242         return b_arr;
3243 }
3244 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3245         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3246         ret->datalen = *((uint32_t*)elems);
3247         if (ret->datalen == 0) {
3248                 ret->data = NULL;
3249         } else {
3250                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3251                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3252                 for (size_t i = 0; i < ret->datalen; i++) {
3253                         uint32_t arr_elem = java_elems[i];
3254                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3255                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3256                         ret->data[i] = arr_elem_conv;
3257                 }
3258         }
3259         return (uint64_t)ret;
3260 }
3261 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3262         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 };
3263         for (size_t i = 0; i < ret.datalen; i++) {
3264                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3265         }
3266         return ret;
3267 }
3268 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3269         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3270         switch(obj->tag) {
3271                 case LDKEvent_FundingGenerationReady: {
3272                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3273                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3274                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3275                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3276                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3277                         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;
3278                 }
3279                 case LDKEvent_PaymentReceived: {
3280                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3281                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3282                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3283                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_received.payment_preimage.data, 32);
3284                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3285                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
3286                         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;
3287                 }
3288                 case LDKEvent_PaymentSent: {
3289                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3290                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3291                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3292                 }
3293                 case LDKEvent_PaymentFailed: {
3294                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3295                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
3296                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
3297                 }
3298                 case LDKEvent_PendingHTLCsForwardable: {
3299                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3300                 }
3301                 case LDKEvent_SpendableOutputs: {
3302                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3303                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3304                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3305                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3306                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3307                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3308                         }
3309                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3310                 }
3311                 default: abort();
3312         }
3313 }
3314 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3315         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3316         ret->datalen = *((uint32_t*)elems);
3317         if (ret->datalen == 0) {
3318                 ret->data = NULL;
3319         } else {
3320                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3321                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3322                 for (size_t i = 0; i < ret->datalen; i++) {
3323                         uint32_t arr_elem = java_elems[i];
3324                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3325                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3326                         ret->data[i] = arr_elem_conv;
3327                 }
3328         }
3329         return (uint64_t)ret;
3330 }
3331 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3332         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3333         for (size_t i = 0; i < ret.datalen; i++) {
3334                 ret.data[i] = Event_clone(&orig->data[i]);
3335         }
3336         return ret;
3337 }
3338 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3339         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3340         ret->a = a;
3341         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3342         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3343         ret->b = b_conv;
3344         return (uint64_t)ret;
3345 }
3346 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
3347         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3348         return tuple->a;
3349 }
3350 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
3351         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
3352         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
3353         return (uint64_t)b_ref;
3354 }
3355 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3356         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3357         ret->datalen = *((uint32_t*)elems);
3358         if (ret->datalen == 0) {
3359                 ret->data = NULL;
3360         } else {
3361                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3362                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3363                 for (size_t i = 0; i < ret->datalen; i++) {
3364                         uint32_t arr_elem = java_elems[i];
3365                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3366                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3367                         ret->data[i] = arr_elem_conv;
3368                 }
3369         }
3370         return (uint64_t)ret;
3371 }
3372 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3373         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3374         for (size_t i = 0; i < ret.datalen; i++) {
3375                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3376         }
3377         return ret;
3378 }
3379 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3380         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3381         LDKThirtyTwoBytes a_ref;
3382         CHECK(*((uint32_t*)a) == 32);
3383         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3384         ret->a = a_ref;
3385         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3386         b_constr.datalen = *((uint32_t*)b);
3387         if (b_constr.datalen > 0)
3388                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3389         else
3390                 b_constr.data = NULL;
3391         uint32_t* b_vals = (uint32_t*)(b + 4);
3392         for (size_t z = 0; z < b_constr.datalen; z++) {
3393                 uint32_t b_conv_25 = b_vals[z];
3394                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
3395                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
3396                 b_constr.data[z] = b_conv_25_conv;
3397         }
3398         ret->b = b_constr;
3399         return (uint64_t)ret;
3400 }
3401 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
3402         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3403         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3404         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
3405         return a_arr;
3406 }
3407 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
3408         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
3409         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
3410         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3411         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
3412         for (size_t z = 0; z < b_var.datalen; z++) {
3413                 uint64_t b_conv_25_ref = (uint64_t)(&b_var.data[z]) | 1;
3414                 b_arr_ptr[z] = b_conv_25_ref;
3415         }
3416         return b_arr;
3417 }
3418 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3419         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3420         ret->datalen = *((uint32_t*)elems);
3421         if (ret->datalen == 0) {
3422                 ret->data = NULL;
3423         } else {
3424                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3425                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3426                 for (size_t i = 0; i < ret->datalen; i++) {
3427                         uint32_t arr_elem = java_elems[i];
3428                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3429                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3430                         ret->data[i] = arr_elem_conv;
3431                 }
3432         }
3433         return (uint64_t)ret;
3434 }
3435 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3436         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 };
3437         for (size_t i = 0; i < ret.datalen; i++) {
3438                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3439         }
3440         return ret;
3441 }
3442 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3443         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3444 }
3445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3446         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3447         CHECK(val->result_ok);
3448         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
3449         return res_ref;
3450 }
3451 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
3452         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
3453         CHECK(!val->result_ok);
3454         LDKDecodeError err_var = (*val->contents.err);
3455         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3456         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3457         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3458         return err_ref;
3459 }
3460 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
3461         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
3462 }
3463 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
3464         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3465         CHECK(val->result_ok);
3466         return *val->contents.result;
3467 }
3468 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
3469         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
3470         CHECK(!val->result_ok);
3471         LDKLightningError err_var = (*val->contents.err);
3472         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3473         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3474         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3475         return err_ref;
3476 }
3477 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
3478         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3479         LDKChannelAnnouncement a_conv;
3480         a_conv.inner = (void*)(a & (~1));
3481         a_conv.is_owned = (a & 1) || (a == 0);
3482         a_conv = ChannelAnnouncement_clone(&a_conv);
3483         ret->a = a_conv;
3484         LDKChannelUpdate b_conv;
3485         b_conv.inner = (void*)(b & (~1));
3486         b_conv.is_owned = (b & 1) || (b == 0);
3487         b_conv = ChannelUpdate_clone(&b_conv);
3488         ret->b = b_conv;
3489         LDKChannelUpdate c_conv;
3490         c_conv.inner = (void*)(c & (~1));
3491         c_conv.is_owned = (c & 1) || (c == 0);
3492         c_conv = ChannelUpdate_clone(&c_conv);
3493         ret->c = c_conv;
3494         return (uint64_t)ret;
3495 }
3496 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
3497         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3498         LDKChannelAnnouncement a_var = tuple->a;
3499         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3500         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3501         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
3502         return a_ref;
3503 }
3504 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
3505         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3506         LDKChannelUpdate b_var = tuple->b;
3507         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3508         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3509         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
3510         return b_ref;
3511 }
3512 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
3513         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
3514         LDKChannelUpdate c_var = tuple->c;
3515         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3516         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3517         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
3518         return c_ref;
3519 }
3520 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
3521         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
3522         ret->datalen = *((uint32_t*)elems);
3523         if (ret->datalen == 0) {
3524                 ret->data = NULL;
3525         } else {
3526                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
3527                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3528                 for (size_t i = 0; i < ret->datalen; i++) {
3529                         uint32_t arr_elem = java_elems[i];
3530                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
3531                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
3532                         ret->data[i] = arr_elem_conv;
3533                 }
3534         }
3535         return (uint64_t)ret;
3536 }
3537 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3538         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3539         for (size_t i = 0; i < ret.datalen; i++) {
3540                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3541         }
3542         return ret;
3543 }
3544 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
3545         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
3546         ret->datalen = *((uint32_t*)elems);
3547         if (ret->datalen == 0) {
3548                 ret->data = NULL;
3549         } else {
3550                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
3551                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3552                 for (size_t i = 0; i < ret->datalen; i++) {
3553                         uint32_t arr_elem = java_elems[i];
3554                         LDKNodeAnnouncement arr_elem_conv;
3555                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3556                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3557                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
3558                         ret->data[i] = arr_elem_conv;
3559                 }
3560         }
3561         return (uint64_t)ret;
3562 }
3563 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3564         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3565         for (size_t i = 0; i < ret.datalen; i++) {
3566                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3567         }
3568         return ret;
3569 }
3570 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
3571         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
3572 }
3573 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
3574         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3575         CHECK(val->result_ok);
3576         return *val->contents.result;
3577 }
3578 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
3579         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
3580         CHECK(!val->result_ok);
3581         LDKLightningError err_var = (*val->contents.err);
3582         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3583         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3584         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3585         return err_ref;
3586 }
3587 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
3588         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
3589 }
3590 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
3591         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3592         CHECK(val->result_ok);
3593         LDKCVec_u8Z res_var = (*val->contents.result);
3594         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3595         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
3596         return res_arr;
3597 }
3598 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
3599         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
3600         CHECK(!val->result_ok);
3601         LDKPeerHandleError err_var = (*val->contents.err);
3602         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3603         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3604         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3605         return err_ref;
3606 }
3607 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
3608         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
3609 }
3610 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
3611         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3612         CHECK(val->result_ok);
3613         return *val->contents.result;
3614 }
3615 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
3616         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
3617         CHECK(!val->result_ok);
3618         LDKPeerHandleError err_var = (*val->contents.err);
3619         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3620         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3621         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3622         return err_ref;
3623 }
3624 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
3625         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
3626 }
3627 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
3628         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3629         CHECK(val->result_ok);
3630         return *val->contents.result;
3631 }
3632 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
3633         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
3634         CHECK(!val->result_ok);
3635         LDKPeerHandleError err_var = (*val->contents.err);
3636         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3637         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3638         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3639         return err_ref;
3640 }
3641 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3642         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
3643 }
3644 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3645         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3646         CHECK(val->result_ok);
3647         LDKDirectionalChannelInfo res_var = (*val->contents.result);
3648         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3649         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3650         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3651         return res_ref;
3652 }
3653 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3654         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
3655         CHECK(!val->result_ok);
3656         LDKDecodeError err_var = (*val->contents.err);
3657         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3658         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3659         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3660         return err_ref;
3661 }
3662 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
3663         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
3664 }
3665 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
3666         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3667         CHECK(val->result_ok);
3668         LDKChannelInfo res_var = (*val->contents.result);
3669         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3670         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3671         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3672         return res_ref;
3673 }
3674 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
3675         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
3676         CHECK(!val->result_ok);
3677         LDKDecodeError err_var = (*val->contents.err);
3678         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3679         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3680         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3681         return err_ref;
3682 }
3683 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
3684         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3685 }
3686 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3687         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3688         CHECK(val->result_ok);
3689         LDKRoutingFees res_var = (*val->contents.result);
3690         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3691         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3692         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3693         return res_ref;
3694 }
3695 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3696         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
3697         CHECK(!val->result_ok);
3698         LDKDecodeError err_var = (*val->contents.err);
3699         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3700         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3701         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3702         return err_ref;
3703 }
3704 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3705         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3706 }
3707 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3708         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3709         CHECK(val->result_ok);
3710         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3711         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3712         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3713         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3714         return res_ref;
3715 }
3716 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3717         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
3718         CHECK(!val->result_ok);
3719         LDKDecodeError err_var = (*val->contents.err);
3720         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3721         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3722         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3723         return err_ref;
3724 }
3725 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
3726         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
3727         ret->datalen = *((uint32_t*)elems);
3728         if (ret->datalen == 0) {
3729                 ret->data = NULL;
3730         } else {
3731                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
3732                 int64_t *java_elems = (int64_t*)(elems + 4);
3733                 for (size_t i = 0; i < ret->datalen; i++) {
3734                         ret->data[i] = java_elems[i];
3735                 }
3736         }
3737         return (uint64_t)ret;
3738 }
3739 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3740         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3741         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3742         return ret;
3743 }
3744 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3745         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3746 }
3747 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3748         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3749         CHECK(val->result_ok);
3750         LDKNodeInfo res_var = (*val->contents.result);
3751         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3752         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3753         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3754         return res_ref;
3755 }
3756 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3757         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
3758         CHECK(!val->result_ok);
3759         LDKDecodeError err_var = (*val->contents.err);
3760         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3761         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3762         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3763         return err_ref;
3764 }
3765 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3766         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3767 }
3768 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3769         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3770         CHECK(val->result_ok);
3771         LDKNetworkGraph res_var = (*val->contents.result);
3772         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3773         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3774         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3775         return res_ref;
3776 }
3777 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3778         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
3779         CHECK(!val->result_ok);
3780         LDKDecodeError err_var = (*val->contents.err);
3781         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3782         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3783         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3784         return err_ref;
3785 }
3786 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3787         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3788 }
3789 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3790         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3791         CHECK(val->result_ok);
3792         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3793         return res_ref;
3794 }
3795 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3796         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3797         CHECK(!val->result_ok);
3798         return *val->contents.err;
3799 }
3800 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3801         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3802 }
3803 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3804         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3805         CHECK(val->result_ok);
3806         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3807         *res_conv = (*val->contents.result);
3808         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3809         return (uint64_t)res_conv;
3810 }
3811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3812         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3813         CHECK(!val->result_ok);
3814         LDKDecodeError err_var = (*val->contents.err);
3815         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3816         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3817         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3818         return err_ref;
3819 }
3820 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
3821         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
3822 }
3823 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
3824         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3825         CHECK(val->result_ok);
3826         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3827         return res_ref;
3828 }
3829 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
3830         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
3831         CHECK(!val->result_ok);
3832         LDKDecodeError err_var = (*val->contents.err);
3833         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3834         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3835         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3836         return err_ref;
3837 }
3838 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3839         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3840         ret->datalen = *((uint32_t*)elems);
3841         if (ret->datalen == 0) {
3842                 ret->data = NULL;
3843         } else {
3844                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3845                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3846                 for (size_t i = 0; i < ret->datalen; i++) {
3847                         uint32_t arr_elem = java_elems[i];
3848                         LDKUpdateAddHTLC arr_elem_conv;
3849                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3850                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3851                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3852                         ret->data[i] = arr_elem_conv;
3853                 }
3854         }
3855         return (uint64_t)ret;
3856 }
3857 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3858         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3859         for (size_t i = 0; i < ret.datalen; i++) {
3860                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3861         }
3862         return ret;
3863 }
3864 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3865         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3866         ret->datalen = *((uint32_t*)elems);
3867         if (ret->datalen == 0) {
3868                 ret->data = NULL;
3869         } else {
3870                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3871                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3872                 for (size_t i = 0; i < ret->datalen; i++) {
3873                         uint32_t arr_elem = java_elems[i];
3874                         LDKUpdateFulfillHTLC arr_elem_conv;
3875                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3876                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3877                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3878                         ret->data[i] = arr_elem_conv;
3879                 }
3880         }
3881         return (uint64_t)ret;
3882 }
3883 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3884         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3885         for (size_t i = 0; i < ret.datalen; i++) {
3886                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3887         }
3888         return ret;
3889 }
3890 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3891         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3892         ret->datalen = *((uint32_t*)elems);
3893         if (ret->datalen == 0) {
3894                 ret->data = NULL;
3895         } else {
3896                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3897                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3898                 for (size_t i = 0; i < ret->datalen; i++) {
3899                         uint32_t arr_elem = java_elems[i];
3900                         LDKUpdateFailHTLC arr_elem_conv;
3901                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3902                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3903                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3904                         ret->data[i] = arr_elem_conv;
3905                 }
3906         }
3907         return (uint64_t)ret;
3908 }
3909 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3910         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3911         for (size_t i = 0; i < ret.datalen; i++) {
3912                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3913         }
3914         return ret;
3915 }
3916 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3917         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3918         ret->datalen = *((uint32_t*)elems);
3919         if (ret->datalen == 0) {
3920                 ret->data = NULL;
3921         } else {
3922                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3923                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3924                 for (size_t i = 0; i < ret->datalen; i++) {
3925                         uint32_t arr_elem = java_elems[i];
3926                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3927                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3928                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3929                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3930                         ret->data[i] = arr_elem_conv;
3931                 }
3932         }
3933         return (uint64_t)ret;
3934 }
3935 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3936         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3937         for (size_t i = 0; i < ret.datalen; i++) {
3938                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3939         }
3940         return ret;
3941 }
3942 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3943         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3944 }
3945 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3946         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3947         CHECK(val->result_ok);
3948         LDKAcceptChannel res_var = (*val->contents.result);
3949         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3950         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3951         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3952         return res_ref;
3953 }
3954 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3955         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3956         CHECK(!val->result_ok);
3957         LDKDecodeError err_var = (*val->contents.err);
3958         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3959         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3960         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3961         return err_ref;
3962 }
3963 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3964         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3965 }
3966 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3967         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3968         CHECK(val->result_ok);
3969         LDKAnnouncementSignatures res_var = (*val->contents.result);
3970         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3971         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3972         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3973         return res_ref;
3974 }
3975 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3976         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3977         CHECK(!val->result_ok);
3978         LDKDecodeError err_var = (*val->contents.err);
3979         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3980         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3981         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3982         return err_ref;
3983 }
3984 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
3985         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3986 }
3987 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
3988         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3989         CHECK(val->result_ok);
3990         LDKChannelReestablish res_var = (*val->contents.result);
3991         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3992         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3993         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3994         return res_ref;
3995 }
3996 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
3997         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3998         CHECK(!val->result_ok);
3999         LDKDecodeError err_var = (*val->contents.err);
4000         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4001         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4002         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4003         return err_ref;
4004 }
4005 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4006         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4007 }
4008 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4009         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4010         CHECK(val->result_ok);
4011         LDKClosingSigned res_var = (*val->contents.result);
4012         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4013         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4014         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4015         return res_ref;
4016 }
4017 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4018         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4019         CHECK(!val->result_ok);
4020         LDKDecodeError err_var = (*val->contents.err);
4021         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4022         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4023         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4024         return err_ref;
4025 }
4026 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4027         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4028 }
4029 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4030         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4031         CHECK(val->result_ok);
4032         LDKCommitmentSigned res_var = (*val->contents.result);
4033         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4034         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4035         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4036         return res_ref;
4037 }
4038 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4039         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4040         CHECK(!val->result_ok);
4041         LDKDecodeError err_var = (*val->contents.err);
4042         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4043         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4044         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4045         return err_ref;
4046 }
4047 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4048         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4049 }
4050 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4051         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4052         CHECK(val->result_ok);
4053         LDKFundingCreated res_var = (*val->contents.result);
4054         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4055         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4056         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4057         return res_ref;
4058 }
4059 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4060         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4061         CHECK(!val->result_ok);
4062         LDKDecodeError err_var = (*val->contents.err);
4063         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4064         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4065         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4066         return err_ref;
4067 }
4068 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4069         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4070 }
4071 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4072         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4073         CHECK(val->result_ok);
4074         LDKFundingSigned res_var = (*val->contents.result);
4075         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4076         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4077         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4078         return res_ref;
4079 }
4080 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4081         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4082         CHECK(!val->result_ok);
4083         LDKDecodeError err_var = (*val->contents.err);
4084         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4085         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4086         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4087         return err_ref;
4088 }
4089 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4090         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4091 }
4092 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4093         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4094         CHECK(val->result_ok);
4095         LDKFundingLocked res_var = (*val->contents.result);
4096         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4097         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4098         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4099         return res_ref;
4100 }
4101 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4102         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4103         CHECK(!val->result_ok);
4104         LDKDecodeError err_var = (*val->contents.err);
4105         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4106         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4107         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4108         return err_ref;
4109 }
4110 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4111         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4112 }
4113 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4114         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4115         CHECK(val->result_ok);
4116         LDKInit res_var = (*val->contents.result);
4117         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4118         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4119         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4120         return res_ref;
4121 }
4122 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4123         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4124         CHECK(!val->result_ok);
4125         LDKDecodeError err_var = (*val->contents.err);
4126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4128         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4129         return err_ref;
4130 }
4131 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4132         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4133 }
4134 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4135         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4136         CHECK(val->result_ok);
4137         LDKOpenChannel res_var = (*val->contents.result);
4138         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4139         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4140         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4141         return res_ref;
4142 }
4143 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4144         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4145         CHECK(!val->result_ok);
4146         LDKDecodeError err_var = (*val->contents.err);
4147         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4148         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4149         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4150         return err_ref;
4151 }
4152 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4153         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4154 }
4155 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4156         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4157         CHECK(val->result_ok);
4158         LDKRevokeAndACK res_var = (*val->contents.result);
4159         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4160         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4161         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4162         return res_ref;
4163 }
4164 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4165         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4166         CHECK(!val->result_ok);
4167         LDKDecodeError err_var = (*val->contents.err);
4168         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4169         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4170         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4171         return err_ref;
4172 }
4173 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4174         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4175 }
4176 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4177         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4178         CHECK(val->result_ok);
4179         LDKShutdown res_var = (*val->contents.result);
4180         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4181         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4182         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4183         return res_ref;
4184 }
4185 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4186         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4187         CHECK(!val->result_ok);
4188         LDKDecodeError err_var = (*val->contents.err);
4189         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4190         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4191         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4192         return err_ref;
4193 }
4194 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4195         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4196 }
4197 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4198         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4199         CHECK(val->result_ok);
4200         LDKUpdateFailHTLC res_var = (*val->contents.result);
4201         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4202         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4203         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4204         return res_ref;
4205 }
4206 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4207         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4208         CHECK(!val->result_ok);
4209         LDKDecodeError err_var = (*val->contents.err);
4210         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4211         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4212         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4213         return err_ref;
4214 }
4215 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4216         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4217 }
4218 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4219         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4220         CHECK(val->result_ok);
4221         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4222         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4225         return res_ref;
4226 }
4227 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4228         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4229         CHECK(!val->result_ok);
4230         LDKDecodeError err_var = (*val->contents.err);
4231         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4232         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4233         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4234         return err_ref;
4235 }
4236 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4237         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4238 }
4239 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4240         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4241         CHECK(val->result_ok);
4242         LDKUpdateFee res_var = (*val->contents.result);
4243         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4244         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4245         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4246         return res_ref;
4247 }
4248 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4249         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4250         CHECK(!val->result_ok);
4251         LDKDecodeError err_var = (*val->contents.err);
4252         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4253         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4254         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4255         return err_ref;
4256 }
4257 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4258         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4259 }
4260 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4261         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4262         CHECK(val->result_ok);
4263         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4264         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4265         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4266         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4267         return res_ref;
4268 }
4269 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4270         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4271         CHECK(!val->result_ok);
4272         LDKDecodeError err_var = (*val->contents.err);
4273         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4276         return err_ref;
4277 }
4278 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4279         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4280 }
4281 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4282         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4283         CHECK(val->result_ok);
4284         LDKUpdateAddHTLC res_var = (*val->contents.result);
4285         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4286         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4287         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4288         return res_ref;
4289 }
4290 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4291         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4292         CHECK(!val->result_ok);
4293         LDKDecodeError err_var = (*val->contents.err);
4294         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4295         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4296         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4297         return err_ref;
4298 }
4299 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
4300         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
4301 }
4302 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4303         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4304         CHECK(val->result_ok);
4305         LDKPing res_var = (*val->contents.result);
4306         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4307         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4308         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4309         return res_ref;
4310 }
4311 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4312         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4313         CHECK(!val->result_ok);
4314         LDKDecodeError err_var = (*val->contents.err);
4315         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4316         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4317         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4318         return err_ref;
4319 }
4320 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
4321         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
4322 }
4323 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4324         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4325         CHECK(val->result_ok);
4326         LDKPong res_var = (*val->contents.result);
4327         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4328         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4329         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4330         return res_ref;
4331 }
4332 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4333         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4334         CHECK(!val->result_ok);
4335         LDKDecodeError err_var = (*val->contents.err);
4336         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4337         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4338         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4339         return err_ref;
4340 }
4341 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4342         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4343 }
4344 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4345         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4346         CHECK(val->result_ok);
4347         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4348         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4349         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4350         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4351         return res_ref;
4352 }
4353 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4354         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4355         CHECK(!val->result_ok);
4356         LDKDecodeError err_var = (*val->contents.err);
4357         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4358         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4359         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4360         return err_ref;
4361 }
4362 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4363         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
4364 }
4365 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4366         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4367         CHECK(val->result_ok);
4368         LDKChannelAnnouncement res_var = (*val->contents.result);
4369         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4370         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4371         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4372         return res_ref;
4373 }
4374 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4375         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4376         CHECK(!val->result_ok);
4377         LDKDecodeError err_var = (*val->contents.err);
4378         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4379         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4380         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4381         return err_ref;
4382 }
4383 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4384         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
4385 }
4386 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4387         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4388         CHECK(val->result_ok);
4389         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
4390         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4391         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4392         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4393         return res_ref;
4394 }
4395 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4396         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
4397         CHECK(!val->result_ok);
4398         LDKDecodeError err_var = (*val->contents.err);
4399         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4400         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4401         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4402         return err_ref;
4403 }
4404 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
4405         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
4406 }
4407 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
4408         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4409         CHECK(val->result_ok);
4410         LDKChannelUpdate res_var = (*val->contents.result);
4411         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4412         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4413         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4414         return res_ref;
4415 }
4416 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
4417         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
4418         CHECK(!val->result_ok);
4419         LDKDecodeError err_var = (*val->contents.err);
4420         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4421         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4422         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4423         return err_ref;
4424 }
4425 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
4426         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
4427 }
4428 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
4429         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4430         CHECK(val->result_ok);
4431         LDKErrorMessage res_var = (*val->contents.result);
4432         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4433         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4434         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4435         return res_ref;
4436 }
4437 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
4438         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
4439         CHECK(!val->result_ok);
4440         LDKDecodeError err_var = (*val->contents.err);
4441         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4442         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4443         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4444         return err_ref;
4445 }
4446 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4447         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4448 }
4449 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4450         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4451         CHECK(val->result_ok);
4452         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
4453         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4454         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4455         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4456         return res_ref;
4457 }
4458 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4459         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
4460         CHECK(!val->result_ok);
4461         LDKDecodeError err_var = (*val->contents.err);
4462         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4463         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4464         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4465         return err_ref;
4466 }
4467 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
4468         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
4469 }
4470 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4471         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4472         CHECK(val->result_ok);
4473         LDKNodeAnnouncement res_var = (*val->contents.result);
4474         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4475         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4476         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4477         return res_ref;
4478 }
4479 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4480         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
4481         CHECK(!val->result_ok);
4482         LDKDecodeError err_var = (*val->contents.err);
4483         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4486         return err_ref;
4487 }
4488 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
4489         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
4490 }
4491 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
4492         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4493         CHECK(val->result_ok);
4494         LDKQueryShortChannelIds res_var = (*val->contents.result);
4495         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4496         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4497         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4498         return res_ref;
4499 }
4500 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
4501         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
4502         CHECK(!val->result_ok);
4503         LDKDecodeError err_var = (*val->contents.err);
4504         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4505         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4506         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4507         return err_ref;
4508 }
4509 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
4510         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
4511 }
4512 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
4513         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4514         CHECK(val->result_ok);
4515         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
4516         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4517         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4518         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4519         return res_ref;
4520 }
4521 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
4522         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
4523         CHECK(!val->result_ok);
4524         LDKDecodeError err_var = (*val->contents.err);
4525         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4526         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4527         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4528         return err_ref;
4529 }
4530 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4531         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
4532 }
4533 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4534         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4535         CHECK(val->result_ok);
4536         LDKQueryChannelRange res_var = (*val->contents.result);
4537         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4538         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4539         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4540         return res_ref;
4541 }
4542 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4543         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
4544         CHECK(!val->result_ok);
4545         LDKDecodeError err_var = (*val->contents.err);
4546         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4547         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4548         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4549         return err_ref;
4550 }
4551 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
4552         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
4553 }
4554 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
4555         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4556         CHECK(val->result_ok);
4557         LDKReplyChannelRange res_var = (*val->contents.result);
4558         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4559         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4560         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4561         return res_ref;
4562 }
4563 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
4564         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
4565         CHECK(!val->result_ok);
4566         LDKDecodeError err_var = (*val->contents.err);
4567         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4568         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4569         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4570         return err_ref;
4571 }
4572 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
4573         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
4574 }
4575 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
4576         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4577         CHECK(val->result_ok);
4578         LDKGossipTimestampFilter res_var = (*val->contents.result);
4579         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4580         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4581         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4582         return res_ref;
4583 }
4584 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
4585         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
4586         CHECK(!val->result_ok);
4587         LDKDecodeError err_var = (*val->contents.err);
4588         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4589         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4590         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4591         return err_ref;
4592 }
4593 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
4594         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
4595         switch(obj->tag) {
4596                 case LDKSignOrCreationError_SignError: {
4597                         return 0 /* LDKSignOrCreationError - SignError */;
4598                 }
4599                 case LDKSignOrCreationError_CreationError: {
4600                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
4601                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
4602                 }
4603                 default: abort();
4604         }
4605 }
4606 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
4607         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
4608 }
4609 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
4610         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4611         CHECK(val->result_ok);
4612         LDKInvoice res_var = (*val->contents.result);
4613         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4614         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4615         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4616         return res_ref;
4617 }
4618 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
4619         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
4620         CHECK(!val->result_ok);
4621         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4622         return err_ref;
4623 }
4624 typedef struct LDKMessageSendEventsProvider_JCalls {
4625         atomic_size_t refcnt;
4626         uint32_t get_and_clear_pending_msg_events_meth;
4627 } LDKMessageSendEventsProvider_JCalls;
4628 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
4629         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4630         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4631                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
4632                 FREE(j_calls);
4633         }
4634 }
4635 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
4636         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4637         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
4638         LDKCVec_MessageSendEventZ ret_constr;
4639         ret_constr.datalen = *((uint32_t*)ret);
4640         if (ret_constr.datalen > 0)
4641                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4642         else
4643                 ret_constr.data = NULL;
4644         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4645         for (size_t s = 0; s < ret_constr.datalen; s++) {
4646                 uint32_t ret_conv_18 = ret_vals[s];
4647                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
4648                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
4649                 ret_constr.data[s] = ret_conv_18_conv;
4650         }
4651         return ret_constr;
4652 }
4653 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
4654         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
4655         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4656         return (void*) this_arg;
4657 }
4658 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4659         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
4660         atomic_init(&calls->refcnt, 1);
4661         //TODO: Assign calls->o from o
4662
4663         LDKMessageSendEventsProvider ret = {
4664                 .this_arg = (void*) calls,
4665                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
4666                 .free = LDKMessageSendEventsProvider_JCalls_free,
4667         };
4668         return ret;
4669 }
4670 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4671         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
4672         *res_ptr = LDKMessageSendEventsProvider_init(o);
4673         return (long)res_ptr;
4674 }
4675 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
4676         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
4677         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
4678         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4679         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4680         for (size_t s = 0; s < ret_var.datalen; s++) {
4681                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4682                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
4683                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
4684                 ret_arr_ptr[s] = ret_conv_18_ref;
4685         }
4686         FREE(ret_var.data);
4687         return ret_arr;
4688 }
4689
4690 typedef struct LDKEventHandler_JCalls {
4691         atomic_size_t refcnt;
4692         uint32_t handle_event_meth;
4693 } LDKEventHandler_JCalls;
4694 static void LDKEventHandler_JCalls_free(void* this_arg) {
4695         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4697                 js_free(j_calls->handle_event_meth);
4698                 FREE(j_calls);
4699         }
4700 }
4701 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
4702         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4703         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4704         *event_copy = event;
4705         uint64_t event_ref = (uint64_t)event_copy;
4706         js_invoke_function_1(j_calls->handle_event_meth, event_ref);
4707 }
4708 static void* LDKEventHandler_JCalls_clone(const void* this_arg) {
4709         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
4710         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4711         return (void*) this_arg;
4712 }
4713 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
4714         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
4715         atomic_init(&calls->refcnt, 1);
4716         //TODO: Assign calls->o from o
4717
4718         LDKEventHandler ret = {
4719                 .this_arg = (void*) calls,
4720                 .handle_event = handle_event_LDKEventHandler_jcall,
4721                 .free = LDKEventHandler_JCalls_free,
4722         };
4723         return ret;
4724 }
4725 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
4726         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4727         *res_ptr = LDKEventHandler_init(o);
4728         return (long)res_ptr;
4729 }
4730 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
4731         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
4732         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
4733         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
4734 }
4735
4736 typedef struct LDKEventsProvider_JCalls {
4737         atomic_size_t refcnt;
4738         uint32_t process_pending_events_meth;
4739 } LDKEventsProvider_JCalls;
4740 static void LDKEventsProvider_JCalls_free(void* this_arg) {
4741         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4742         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4743                 js_free(j_calls->process_pending_events_meth);
4744                 FREE(j_calls);
4745         }
4746 }
4747 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
4748         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4749         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
4750         *ret = handler;
4751         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret);
4752 }
4753 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
4754         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
4755         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4756         return (void*) this_arg;
4757 }
4758 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
4759         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
4760         atomic_init(&calls->refcnt, 1);
4761         //TODO: Assign calls->o from o
4762
4763         LDKEventsProvider ret = {
4764                 .this_arg = (void*) calls,
4765                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
4766                 .free = LDKEventsProvider_JCalls_free,
4767         };
4768         return ret;
4769 }
4770 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
4771         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
4772         *res_ptr = LDKEventsProvider_init(o);
4773         return (long)res_ptr;
4774 }
4775 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
4776         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
4777         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
4778         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
4779 }
4780
4781 typedef struct LDKAccess_JCalls {
4782         atomic_size_t refcnt;
4783         uint32_t get_utxo_meth;
4784 } LDKAccess_JCalls;
4785 static void LDKAccess_JCalls_free(void* this_arg) {
4786         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4787         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4788                 js_free(j_calls->get_utxo_meth);
4789                 FREE(j_calls);
4790         }
4791 }
4792 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4793         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4794         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4795         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4796         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4797         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4798         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4799         return ret_conv;
4800 }
4801 static void* LDKAccess_JCalls_clone(const void* this_arg) {
4802         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4804         return (void*) this_arg;
4805 }
4806 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4807         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4808         atomic_init(&calls->refcnt, 1);
4809         //TODO: Assign calls->o from o
4810
4811         LDKAccess ret = {
4812                 .this_arg = (void*) calls,
4813                 .get_utxo = get_utxo_LDKAccess_jcall,
4814                 .free = LDKAccess_JCalls_free,
4815         };
4816         return ret;
4817 }
4818 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4819         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4820         *res_ptr = LDKAccess_init(o);
4821         return (long)res_ptr;
4822 }
4823 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4824         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4825         unsigned char genesis_hash_arr[32];
4826         CHECK(*((uint32_t*)genesis_hash) == 32);
4827         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4828         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4829         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4830         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4831         return (uint64_t)ret_conv;
4832 }
4833
4834 typedef struct LDKListen_JCalls {
4835         atomic_size_t refcnt;
4836         uint32_t block_connected_meth;
4837         uint32_t block_disconnected_meth;
4838 } LDKListen_JCalls;
4839 static void LDKListen_JCalls_free(void* this_arg) {
4840         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4841         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4842                 js_free(j_calls->block_connected_meth);
4843                 js_free(j_calls->block_disconnected_meth);
4844                 FREE(j_calls);
4845         }
4846 }
4847 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4848         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4849         LDKu8slice block_var = block;
4850         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4851         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4852         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4853 }
4854 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4855         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4856         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4857         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4858         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4859 }
4860 static void* LDKListen_JCalls_clone(const void* this_arg) {
4861         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4862         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4863         return (void*) this_arg;
4864 }
4865 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4866         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4867         atomic_init(&calls->refcnt, 1);
4868         //TODO: Assign calls->o from o
4869
4870         LDKListen ret = {
4871                 .this_arg = (void*) calls,
4872                 .block_connected = block_connected_LDKListen_jcall,
4873                 .block_disconnected = block_disconnected_LDKListen_jcall,
4874                 .free = LDKListen_JCalls_free,
4875         };
4876         return ret;
4877 }
4878 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4879         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4880         *res_ptr = LDKListen_init(o);
4881         return (long)res_ptr;
4882 }
4883 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4884         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4885         LDKu8slice block_ref;
4886         block_ref.datalen = *((uint32_t*)block);
4887         block_ref.data = (int8_t*)(block + 4);
4888         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4889 }
4890
4891 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4892         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4893         unsigned char header_arr[80];
4894         CHECK(*((uint32_t*)header) == 80);
4895         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4896         unsigned char (*header_ref)[80] = &header_arr;
4897         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4898 }
4899
4900 typedef struct LDKConfirm_JCalls {
4901         atomic_size_t refcnt;
4902         uint32_t transactions_confirmed_meth;
4903         uint32_t transaction_unconfirmed_meth;
4904         uint32_t best_block_updated_meth;
4905         uint32_t get_relevant_txids_meth;
4906 } LDKConfirm_JCalls;
4907 static void LDKConfirm_JCalls_free(void* this_arg) {
4908         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4909         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4910                 js_free(j_calls->transactions_confirmed_meth);
4911                 js_free(j_calls->transaction_unconfirmed_meth);
4912                 js_free(j_calls->best_block_updated_meth);
4913                 js_free(j_calls->get_relevant_txids_meth);
4914                 FREE(j_calls);
4915         }
4916 }
4917 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
4918         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4919         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4920         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4921         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
4922         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4923         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
4924         for (size_t e = 0; e < txdata_var.datalen; e++) {
4925                 LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4926                 *txdata_conv_30_ref = txdata_var.data[e];
4927                 txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
4928         }
4929         FREE(txdata_var.data);
4930         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
4931 }
4932 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
4933         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4934         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4935         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4936         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
4937 }
4938 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4939         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4940         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4941         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4942         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
4943 }
4944 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
4945         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4946         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
4947         LDKCVec_TxidZ ret_constr;
4948         ret_constr.datalen = *((uint32_t*)ret);
4949         if (ret_constr.datalen > 0)
4950                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
4951         else
4952                 ret_constr.data = NULL;
4953         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
4954         for (size_t m = 0; m < ret_constr.datalen; m++) {
4955                 int8_tArray ret_conv_12 = ret_vals[m];
4956                 LDKThirtyTwoBytes ret_conv_12_ref;
4957                 CHECK(*((uint32_t*)ret_conv_12) == 32);
4958                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
4959                 ret_constr.data[m] = ret_conv_12_ref;
4960         }
4961         return ret_constr;
4962 }
4963 static void* LDKConfirm_JCalls_clone(const void* this_arg) {
4964         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
4965         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4966         return (void*) this_arg;
4967 }
4968 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
4969         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
4970         atomic_init(&calls->refcnt, 1);
4971         //TODO: Assign calls->o from o
4972
4973         LDKConfirm ret = {
4974                 .this_arg = (void*) calls,
4975                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
4976                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
4977                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
4978                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
4979                 .free = LDKConfirm_JCalls_free,
4980         };
4981         return ret;
4982 }
4983 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
4984         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
4985         *res_ptr = LDKConfirm_init(o);
4986         return (long)res_ptr;
4987 }
4988 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
4989         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
4990         unsigned char header_arr[80];
4991         CHECK(*((uint32_t*)header) == 80);
4992         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4993         unsigned char (*header_ref)[80] = &header_arr;
4994         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
4995         txdata_constr.datalen = *((uint32_t*)txdata);
4996         if (txdata_constr.datalen > 0)
4997                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4998         else
4999                 txdata_constr.data = NULL;
5000         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5001         for (size_t e = 0; e < txdata_constr.datalen; e++) {
5002                 uint32_t txdata_conv_30 = txdata_vals[e];
5003                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
5004                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
5005                 txdata_constr.data[e] = txdata_conv_30_conv;
5006         }
5007         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5008 }
5009
5010 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5011         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5012         unsigned char txid_arr[32];
5013         CHECK(*((uint32_t*)txid) == 32);
5014         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5015         unsigned char (*txid_ref)[32] = &txid_arr;
5016         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5017 }
5018
5019 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5020         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5021         unsigned char header_arr[80];
5022         CHECK(*((uint32_t*)header) == 80);
5023         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5024         unsigned char (*header_ref)[80] = &header_arr;
5025         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5026 }
5027
5028 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5029         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5030         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5031         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5032         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5033         for (size_t m = 0; m < ret_var.datalen; m++) {
5034                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5035                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5036                 ret_arr_ptr[m] = ret_conv_12_arr;
5037         }
5038         FREE(ret_var.data);
5039         return ret_arr;
5040 }
5041
5042 typedef struct LDKFilter_JCalls {
5043         atomic_size_t refcnt;
5044         uint32_t register_tx_meth;
5045         uint32_t register_output_meth;
5046 } LDKFilter_JCalls;
5047 static void LDKFilter_JCalls_free(void* this_arg) {
5048         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5049         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5050                 js_free(j_calls->register_tx_meth);
5051                 js_free(j_calls->register_output_meth);
5052                 FREE(j_calls);
5053         }
5054 }
5055 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5056         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5057         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5058         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5059         LDKu8slice script_pubkey_var = script_pubkey;
5060         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5061         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5062         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5063 }
5064 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5065         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5066         LDKWatchedOutput output_var = output;
5067         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5068         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5069         uint64_t output_ref = (uint64_t)output_var.inner;
5070         if (output_var.is_owned) {
5071                 output_ref |= 1;
5072         }
5073         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
5074         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5075         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5076         return ret_conv;
5077 }
5078 static void* LDKFilter_JCalls_clone(const void* this_arg) {
5079         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5080         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5081         return (void*) this_arg;
5082 }
5083 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5084         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5085         atomic_init(&calls->refcnt, 1);
5086         //TODO: Assign calls->o from o
5087
5088         LDKFilter ret = {
5089                 .this_arg = (void*) calls,
5090                 .register_tx = register_tx_LDKFilter_jcall,
5091                 .register_output = register_output_LDKFilter_jcall,
5092                 .free = LDKFilter_JCalls_free,
5093         };
5094         return ret;
5095 }
5096 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5097         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5098         *res_ptr = LDKFilter_init(o);
5099         return (long)res_ptr;
5100 }
5101 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5102         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5103         unsigned char txid_arr[32];
5104         CHECK(*((uint32_t*)txid) == 32);
5105         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5106         unsigned char (*txid_ref)[32] = &txid_arr;
5107         LDKu8slice script_pubkey_ref;
5108         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5109         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5110         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5111 }
5112
5113 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5114         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5115         LDKWatchedOutput output_conv;
5116         output_conv.inner = (void*)(output & (~1));
5117         output_conv.is_owned = (output & 1) || (output == 0);
5118         output_conv = WatchedOutput_clone(&output_conv);
5119         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5120         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5121         uint64_t ret_ref = (uint64_t)ret_copy;
5122         return ret_ref;
5123 }
5124
5125 typedef struct LDKPersist_JCalls {
5126         atomic_size_t refcnt;
5127         uint32_t persist_new_channel_meth;
5128         uint32_t update_persisted_channel_meth;
5129 } LDKPersist_JCalls;
5130 static void LDKPersist_JCalls_free(void* this_arg) {
5131         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5132         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5133                 js_free(j_calls->persist_new_channel_meth);
5134                 js_free(j_calls->update_persisted_channel_meth);
5135                 FREE(j_calls);
5136         }
5137 }
5138 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5139         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5140         LDKOutPoint id_var = id;
5141         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5142         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5143         uint64_t id_ref = (uint64_t)id_var.inner;
5144         if (id_var.is_owned) {
5145                 id_ref |= 1;
5146         }
5147         LDKChannelMonitor data_var = *data;
5148         data_var = ChannelMonitor_clone(data);
5149         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5150         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5151         uint64_t data_ref = (uint64_t)data_var.inner;
5152         if (data_var.is_owned) {
5153                 data_ref |= 1;
5154         }
5155         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5156         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5157         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5158         return ret_conv;
5159 }
5160 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5161         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5162         LDKOutPoint id_var = id;
5163         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5164         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5165         uint64_t id_ref = (uint64_t)id_var.inner;
5166         if (id_var.is_owned) {
5167                 id_ref |= 1;
5168         }
5169         LDKChannelMonitorUpdate update_var = *update;
5170         update_var = ChannelMonitorUpdate_clone(update);
5171         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5172         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5173         uint64_t update_ref = (uint64_t)update_var.inner;
5174         if (update_var.is_owned) {
5175                 update_ref |= 1;
5176         }
5177         LDKChannelMonitor data_var = *data;
5178         data_var = ChannelMonitor_clone(data);
5179         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         uint64_t data_ref = (uint64_t)data_var.inner;
5182         if (data_var.is_owned) {
5183                 data_ref |= 1;
5184         }
5185         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5186         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5187         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5188         return ret_conv;
5189 }
5190 static void* LDKPersist_JCalls_clone(const void* this_arg) {
5191         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5192         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5193         return (void*) this_arg;
5194 }
5195 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5196         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5197         atomic_init(&calls->refcnt, 1);
5198         //TODO: Assign calls->o from o
5199
5200         LDKPersist ret = {
5201                 .this_arg = (void*) calls,
5202                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5203                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5204                 .free = LDKPersist_JCalls_free,
5205         };
5206         return ret;
5207 }
5208 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5209         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5210         *res_ptr = LDKPersist_init(o);
5211         return (long)res_ptr;
5212 }
5213 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5214         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5215         LDKOutPoint id_conv;
5216         id_conv.inner = (void*)(id & (~1));
5217         id_conv.is_owned = (id & 1) || (id == 0);
5218         id_conv = OutPoint_clone(&id_conv);
5219         LDKChannelMonitor data_conv;
5220         data_conv.inner = (void*)(data & (~1));
5221         data_conv.is_owned = false;
5222         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5223         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5224         return (uint64_t)ret_conv;
5225 }
5226
5227 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5228         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5229         LDKOutPoint id_conv;
5230         id_conv.inner = (void*)(id & (~1));
5231         id_conv.is_owned = (id & 1) || (id == 0);
5232         id_conv = OutPoint_clone(&id_conv);
5233         LDKChannelMonitorUpdate update_conv;
5234         update_conv.inner = (void*)(update & (~1));
5235         update_conv.is_owned = false;
5236         LDKChannelMonitor data_conv;
5237         data_conv.inner = (void*)(data & (~1));
5238         data_conv.is_owned = false;
5239         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5240         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5241         return (uint64_t)ret_conv;
5242 }
5243
5244 typedef struct LDKChannelMessageHandler_JCalls {
5245         atomic_size_t refcnt;
5246         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5247         uint32_t handle_open_channel_meth;
5248         uint32_t handle_accept_channel_meth;
5249         uint32_t handle_funding_created_meth;
5250         uint32_t handle_funding_signed_meth;
5251         uint32_t handle_funding_locked_meth;
5252         uint32_t handle_shutdown_meth;
5253         uint32_t handle_closing_signed_meth;
5254         uint32_t handle_update_add_htlc_meth;
5255         uint32_t handle_update_fulfill_htlc_meth;
5256         uint32_t handle_update_fail_htlc_meth;
5257         uint32_t handle_update_fail_malformed_htlc_meth;
5258         uint32_t handle_commitment_signed_meth;
5259         uint32_t handle_revoke_and_ack_meth;
5260         uint32_t handle_update_fee_meth;
5261         uint32_t handle_announcement_signatures_meth;
5262         uint32_t peer_disconnected_meth;
5263         uint32_t peer_connected_meth;
5264         uint32_t handle_channel_reestablish_meth;
5265         uint32_t handle_channel_update_meth;
5266         uint32_t handle_error_meth;
5267 } LDKChannelMessageHandler_JCalls;
5268 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5269         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5270         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5271                 js_free(j_calls->handle_open_channel_meth);
5272                 js_free(j_calls->handle_accept_channel_meth);
5273                 js_free(j_calls->handle_funding_created_meth);
5274                 js_free(j_calls->handle_funding_signed_meth);
5275                 js_free(j_calls->handle_funding_locked_meth);
5276                 js_free(j_calls->handle_shutdown_meth);
5277                 js_free(j_calls->handle_closing_signed_meth);
5278                 js_free(j_calls->handle_update_add_htlc_meth);
5279                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5280                 js_free(j_calls->handle_update_fail_htlc_meth);
5281                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5282                 js_free(j_calls->handle_commitment_signed_meth);
5283                 js_free(j_calls->handle_revoke_and_ack_meth);
5284                 js_free(j_calls->handle_update_fee_meth);
5285                 js_free(j_calls->handle_announcement_signatures_meth);
5286                 js_free(j_calls->peer_disconnected_meth);
5287                 js_free(j_calls->peer_connected_meth);
5288                 js_free(j_calls->handle_channel_reestablish_meth);
5289                 js_free(j_calls->handle_channel_update_meth);
5290                 js_free(j_calls->handle_error_meth);
5291                 FREE(j_calls);
5292         }
5293 }
5294 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5295         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5296         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5297         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5298         LDKInitFeatures their_features_var = their_features;
5299         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5300         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5301         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5302         if (their_features_var.is_owned) {
5303                 their_features_ref |= 1;
5304         }
5305         LDKOpenChannel msg_var = *msg;
5306         msg_var = OpenChannel_clone(msg);
5307         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5308         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5309         uint64_t msg_ref = (uint64_t)msg_var.inner;
5310         if (msg_var.is_owned) {
5311                 msg_ref |= 1;
5312         }
5313         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5314 }
5315 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5316         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5317         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5318         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5319         LDKInitFeatures their_features_var = their_features;
5320         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5321         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5322         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5323         if (their_features_var.is_owned) {
5324                 their_features_ref |= 1;
5325         }
5326         LDKAcceptChannel msg_var = *msg;
5327         msg_var = AcceptChannel_clone(msg);
5328         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5329         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5330         uint64_t msg_ref = (uint64_t)msg_var.inner;
5331         if (msg_var.is_owned) {
5332                 msg_ref |= 1;
5333         }
5334         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5335 }
5336 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
5337         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5338         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5339         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5340         LDKFundingCreated msg_var = *msg;
5341         msg_var = FundingCreated_clone(msg);
5342         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5343         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5344         uint64_t msg_ref = (uint64_t)msg_var.inner;
5345         if (msg_var.is_owned) {
5346                 msg_ref |= 1;
5347         }
5348         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
5349 }
5350 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
5351         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5352         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5353         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5354         LDKFundingSigned msg_var = *msg;
5355         msg_var = FundingSigned_clone(msg);
5356         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5357         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5358         uint64_t msg_ref = (uint64_t)msg_var.inner;
5359         if (msg_var.is_owned) {
5360                 msg_ref |= 1;
5361         }
5362         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
5363 }
5364 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
5365         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5366         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5367         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5368         LDKFundingLocked msg_var = *msg;
5369         msg_var = FundingLocked_clone(msg);
5370         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5371         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5372         uint64_t msg_ref = (uint64_t)msg_var.inner;
5373         if (msg_var.is_owned) {
5374                 msg_ref |= 1;
5375         }
5376         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
5377 }
5378 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
5379         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5380         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5381         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5382         LDKInitFeatures their_features_var = *their_features;
5383         their_features_var = InitFeatures_clone(their_features);
5384         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5385         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5386         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5387         if (their_features_var.is_owned) {
5388                 their_features_ref |= 1;
5389         }
5390         LDKShutdown msg_var = *msg;
5391         msg_var = Shutdown_clone(msg);
5392         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         uint64_t msg_ref = (uint64_t)msg_var.inner;
5395         if (msg_var.is_owned) {
5396                 msg_ref |= 1;
5397         }
5398         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
5399 }
5400 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
5401         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5402         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5403         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5404         LDKClosingSigned msg_var = *msg;
5405         msg_var = ClosingSigned_clone(msg);
5406         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5407         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5408         uint64_t msg_ref = (uint64_t)msg_var.inner;
5409         if (msg_var.is_owned) {
5410                 msg_ref |= 1;
5411         }
5412         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
5413 }
5414 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
5415         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5416         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5417         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5418         LDKUpdateAddHTLC msg_var = *msg;
5419         msg_var = UpdateAddHTLC_clone(msg);
5420         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5421         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5422         uint64_t msg_ref = (uint64_t)msg_var.inner;
5423         if (msg_var.is_owned) {
5424                 msg_ref |= 1;
5425         }
5426         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
5427 }
5428 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
5429         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5430         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5431         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5432         LDKUpdateFulfillHTLC msg_var = *msg;
5433         msg_var = UpdateFulfillHTLC_clone(msg);
5434         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5435         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5436         uint64_t msg_ref = (uint64_t)msg_var.inner;
5437         if (msg_var.is_owned) {
5438                 msg_ref |= 1;
5439         }
5440         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
5441 }
5442 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
5443         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5444         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5445         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5446         LDKUpdateFailHTLC msg_var = *msg;
5447         msg_var = UpdateFailHTLC_clone(msg);
5448         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5449         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5450         uint64_t msg_ref = (uint64_t)msg_var.inner;
5451         if (msg_var.is_owned) {
5452                 msg_ref |= 1;
5453         }
5454         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
5455 }
5456 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
5457         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5458         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5459         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5460         LDKUpdateFailMalformedHTLC msg_var = *msg;
5461         msg_var = UpdateFailMalformedHTLC_clone(msg);
5462         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5463         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5464         uint64_t msg_ref = (uint64_t)msg_var.inner;
5465         if (msg_var.is_owned) {
5466                 msg_ref |= 1;
5467         }
5468         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
5469 }
5470 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
5471         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5472         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5473         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5474         LDKCommitmentSigned msg_var = *msg;
5475         msg_var = CommitmentSigned_clone(msg);
5476         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5477         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5478         uint64_t msg_ref = (uint64_t)msg_var.inner;
5479         if (msg_var.is_owned) {
5480                 msg_ref |= 1;
5481         }
5482         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
5483 }
5484 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
5485         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5486         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5487         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5488         LDKRevokeAndACK msg_var = *msg;
5489         msg_var = RevokeAndACK_clone(msg);
5490         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5491         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5492         uint64_t msg_ref = (uint64_t)msg_var.inner;
5493         if (msg_var.is_owned) {
5494                 msg_ref |= 1;
5495         }
5496         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
5497 }
5498 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
5499         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5500         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5501         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5502         LDKUpdateFee msg_var = *msg;
5503         msg_var = UpdateFee_clone(msg);
5504         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5505         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5506         uint64_t msg_ref = (uint64_t)msg_var.inner;
5507         if (msg_var.is_owned) {
5508                 msg_ref |= 1;
5509         }
5510         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
5511 }
5512 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
5513         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5514         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5515         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5516         LDKAnnouncementSignatures msg_var = *msg;
5517         msg_var = AnnouncementSignatures_clone(msg);
5518         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5519         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5520         uint64_t msg_ref = (uint64_t)msg_var.inner;
5521         if (msg_var.is_owned) {
5522                 msg_ref |= 1;
5523         }
5524         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
5525 }
5526 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
5527         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5528         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5529         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5530         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
5531 }
5532 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
5533         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5534         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5535         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5536         LDKInit msg_var = *msg;
5537         msg_var = Init_clone(msg);
5538         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5539         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5540         uint64_t msg_ref = (uint64_t)msg_var.inner;
5541         if (msg_var.is_owned) {
5542                 msg_ref |= 1;
5543         }
5544         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
5545 }
5546 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
5547         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5548         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5549         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5550         LDKChannelReestablish msg_var = *msg;
5551         msg_var = ChannelReestablish_clone(msg);
5552         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5553         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5554         uint64_t msg_ref = (uint64_t)msg_var.inner;
5555         if (msg_var.is_owned) {
5556                 msg_ref |= 1;
5557         }
5558         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
5559 }
5560 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
5561         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5562         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5563         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5564         LDKChannelUpdate msg_var = *msg;
5565         msg_var = ChannelUpdate_clone(msg);
5566         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5567         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5568         uint64_t msg_ref = (uint64_t)msg_var.inner;
5569         if (msg_var.is_owned) {
5570                 msg_ref |= 1;
5571         }
5572         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
5573 }
5574 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
5575         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5576         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5577         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5578         LDKErrorMessage msg_var = *msg;
5579         msg_var = ErrorMessage_clone(msg);
5580         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5581         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5582         uint64_t msg_ref = (uint64_t)msg_var.inner;
5583         if (msg_var.is_owned) {
5584                 msg_ref |= 1;
5585         }
5586         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
5587 }
5588 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
5589         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5591         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5592         return (void*) this_arg;
5593 }
5594 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5595         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
5596         atomic_init(&calls->refcnt, 1);
5597         //TODO: Assign calls->o from o
5598
5599         LDKChannelMessageHandler ret = {
5600                 .this_arg = (void*) calls,
5601                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
5602                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
5603                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
5604                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
5605                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
5606                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
5607                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
5608                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
5609                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
5610                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
5611                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
5612                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
5613                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
5614                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
5615                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
5616                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
5617                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
5618                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
5619                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
5620                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
5621                 .free = LDKChannelMessageHandler_JCalls_free,
5622                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5623         };
5624         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5625         return ret;
5626 }
5627 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5628         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
5629         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
5630         return (long)res_ptr;
5631 }
5632 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) {
5633         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5634         LDKPublicKey their_node_id_ref;
5635         CHECK(*((uint32_t*)their_node_id) == 33);
5636         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5637         LDKInitFeatures their_features_conv;
5638         their_features_conv.inner = (void*)(their_features & (~1));
5639         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5640         their_features_conv = InitFeatures_clone(&their_features_conv);
5641         LDKOpenChannel msg_conv;
5642         msg_conv.inner = (void*)(msg & (~1));
5643         msg_conv.is_owned = false;
5644         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5645 }
5646
5647 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) {
5648         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5649         LDKPublicKey their_node_id_ref;
5650         CHECK(*((uint32_t*)their_node_id) == 33);
5651         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5652         LDKInitFeatures their_features_conv;
5653         their_features_conv.inner = (void*)(their_features & (~1));
5654         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
5655         their_features_conv = InitFeatures_clone(&their_features_conv);
5656         LDKAcceptChannel msg_conv;
5657         msg_conv.inner = (void*)(msg & (~1));
5658         msg_conv.is_owned = false;
5659         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
5660 }
5661
5662 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5663         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5664         LDKPublicKey their_node_id_ref;
5665         CHECK(*((uint32_t*)their_node_id) == 33);
5666         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5667         LDKFundingCreated msg_conv;
5668         msg_conv.inner = (void*)(msg & (~1));
5669         msg_conv.is_owned = false;
5670         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5671 }
5672
5673 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5674         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5675         LDKPublicKey their_node_id_ref;
5676         CHECK(*((uint32_t*)their_node_id) == 33);
5677         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5678         LDKFundingSigned msg_conv;
5679         msg_conv.inner = (void*)(msg & (~1));
5680         msg_conv.is_owned = false;
5681         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5682 }
5683
5684 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5685         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5686         LDKPublicKey their_node_id_ref;
5687         CHECK(*((uint32_t*)their_node_id) == 33);
5688         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5689         LDKFundingLocked msg_conv;
5690         msg_conv.inner = (void*)(msg & (~1));
5691         msg_conv.is_owned = false;
5692         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5693 }
5694
5695 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
5696         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5697         LDKPublicKey their_node_id_ref;
5698         CHECK(*((uint32_t*)their_node_id) == 33);
5699         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5700         LDKInitFeatures their_features_conv;
5701         their_features_conv.inner = (void*)(their_features & (~1));
5702         their_features_conv.is_owned = false;
5703         LDKShutdown msg_conv;
5704         msg_conv.inner = (void*)(msg & (~1));
5705         msg_conv.is_owned = false;
5706         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
5707 }
5708
5709 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5710         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5711         LDKPublicKey their_node_id_ref;
5712         CHECK(*((uint32_t*)their_node_id) == 33);
5713         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5714         LDKClosingSigned msg_conv;
5715         msg_conv.inner = (void*)(msg & (~1));
5716         msg_conv.is_owned = false;
5717         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5718 }
5719
5720 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5721         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5722         LDKPublicKey their_node_id_ref;
5723         CHECK(*((uint32_t*)their_node_id) == 33);
5724         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5725         LDKUpdateAddHTLC msg_conv;
5726         msg_conv.inner = (void*)(msg & (~1));
5727         msg_conv.is_owned = false;
5728         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5729 }
5730
5731 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5732         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5733         LDKPublicKey their_node_id_ref;
5734         CHECK(*((uint32_t*)their_node_id) == 33);
5735         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5736         LDKUpdateFulfillHTLC msg_conv;
5737         msg_conv.inner = (void*)(msg & (~1));
5738         msg_conv.is_owned = false;
5739         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5740 }
5741
5742 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5743         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5744         LDKPublicKey their_node_id_ref;
5745         CHECK(*((uint32_t*)their_node_id) == 33);
5746         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5747         LDKUpdateFailHTLC msg_conv;
5748         msg_conv.inner = (void*)(msg & (~1));
5749         msg_conv.is_owned = false;
5750         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5751 }
5752
5753 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5754         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5755         LDKPublicKey their_node_id_ref;
5756         CHECK(*((uint32_t*)their_node_id) == 33);
5757         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5758         LDKUpdateFailMalformedHTLC msg_conv;
5759         msg_conv.inner = (void*)(msg & (~1));
5760         msg_conv.is_owned = false;
5761         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5762 }
5763
5764 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5765         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5766         LDKPublicKey their_node_id_ref;
5767         CHECK(*((uint32_t*)their_node_id) == 33);
5768         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5769         LDKCommitmentSigned msg_conv;
5770         msg_conv.inner = (void*)(msg & (~1));
5771         msg_conv.is_owned = false;
5772         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5773 }
5774
5775 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5776         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5777         LDKPublicKey their_node_id_ref;
5778         CHECK(*((uint32_t*)their_node_id) == 33);
5779         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5780         LDKRevokeAndACK msg_conv;
5781         msg_conv.inner = (void*)(msg & (~1));
5782         msg_conv.is_owned = false;
5783         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5784 }
5785
5786 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5787         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5788         LDKPublicKey their_node_id_ref;
5789         CHECK(*((uint32_t*)their_node_id) == 33);
5790         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5791         LDKUpdateFee msg_conv;
5792         msg_conv.inner = (void*)(msg & (~1));
5793         msg_conv.is_owned = false;
5794         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5795 }
5796
5797 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5798         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5799         LDKPublicKey their_node_id_ref;
5800         CHECK(*((uint32_t*)their_node_id) == 33);
5801         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5802         LDKAnnouncementSignatures msg_conv;
5803         msg_conv.inner = (void*)(msg & (~1));
5804         msg_conv.is_owned = false;
5805         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5806 }
5807
5808 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
5809         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5810         LDKPublicKey their_node_id_ref;
5811         CHECK(*((uint32_t*)their_node_id) == 33);
5812         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5813         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
5814 }
5815
5816 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5817         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5818         LDKPublicKey their_node_id_ref;
5819         CHECK(*((uint32_t*)their_node_id) == 33);
5820         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5821         LDKInit msg_conv;
5822         msg_conv.inner = (void*)(msg & (~1));
5823         msg_conv.is_owned = false;
5824         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5825 }
5826
5827 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5828         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5829         LDKPublicKey their_node_id_ref;
5830         CHECK(*((uint32_t*)their_node_id) == 33);
5831         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5832         LDKChannelReestablish msg_conv;
5833         msg_conv.inner = (void*)(msg & (~1));
5834         msg_conv.is_owned = false;
5835         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5836 }
5837
5838 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5839         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5840         LDKPublicKey their_node_id_ref;
5841         CHECK(*((uint32_t*)their_node_id) == 33);
5842         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5843         LDKChannelUpdate msg_conv;
5844         msg_conv.inner = (void*)(msg & (~1));
5845         msg_conv.is_owned = false;
5846         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5847 }
5848
5849 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5850         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
5851         LDKPublicKey their_node_id_ref;
5852         CHECK(*((uint32_t*)their_node_id) == 33);
5853         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5854         LDKErrorMessage msg_conv;
5855         msg_conv.inner = (void*)(msg & (~1));
5856         msg_conv.is_owned = false;
5857         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
5858 }
5859
5860 typedef struct LDKRoutingMessageHandler_JCalls {
5861         atomic_size_t refcnt;
5862         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5863         uint32_t handle_node_announcement_meth;
5864         uint32_t handle_channel_announcement_meth;
5865         uint32_t handle_channel_update_meth;
5866         uint32_t handle_htlc_fail_channel_update_meth;
5867         uint32_t get_next_channel_announcements_meth;
5868         uint32_t get_next_node_announcements_meth;
5869         uint32_t sync_routing_table_meth;
5870         uint32_t handle_reply_channel_range_meth;
5871         uint32_t handle_reply_short_channel_ids_end_meth;
5872         uint32_t handle_query_channel_range_meth;
5873         uint32_t handle_query_short_channel_ids_meth;
5874 } LDKRoutingMessageHandler_JCalls;
5875 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
5876         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5877         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5878                 js_free(j_calls->handle_node_announcement_meth);
5879                 js_free(j_calls->handle_channel_announcement_meth);
5880                 js_free(j_calls->handle_channel_update_meth);
5881                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
5882                 js_free(j_calls->get_next_channel_announcements_meth);
5883                 js_free(j_calls->get_next_node_announcements_meth);
5884                 js_free(j_calls->sync_routing_table_meth);
5885                 js_free(j_calls->handle_reply_channel_range_meth);
5886                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
5887                 js_free(j_calls->handle_query_channel_range_meth);
5888                 js_free(j_calls->handle_query_short_channel_ids_meth);
5889                 FREE(j_calls);
5890         }
5891 }
5892 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
5893         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5894         LDKNodeAnnouncement msg_var = *msg;
5895         msg_var = NodeAnnouncement_clone(msg);
5896         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         uint64_t msg_ref = (uint64_t)msg_var.inner;
5899         if (msg_var.is_owned) {
5900                 msg_ref |= 1;
5901         }
5902         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
5903         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5904         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5905         return ret_conv;
5906 }
5907 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
5908         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5909         LDKChannelAnnouncement msg_var = *msg;
5910         msg_var = ChannelAnnouncement_clone(msg);
5911         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5912         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5913         uint64_t msg_ref = (uint64_t)msg_var.inner;
5914         if (msg_var.is_owned) {
5915                 msg_ref |= 1;
5916         }
5917         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
5918         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5919         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5920         return ret_conv;
5921 }
5922 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
5923         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5924         LDKChannelUpdate msg_var = *msg;
5925         msg_var = ChannelUpdate_clone(msg);
5926         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         uint64_t msg_ref = (uint64_t)msg_var.inner;
5929         if (msg_var.is_owned) {
5930                 msg_ref |= 1;
5931         }
5932         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
5933         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
5934         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
5935         return ret_conv;
5936 }
5937 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
5938         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5939         uint64_t ret_update = (uint64_t)update;
5940         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
5941 }
5942 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
5943         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5944         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
5945         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
5946         ret_constr.datalen = *((uint32_t*)ret);
5947         if (ret_constr.datalen > 0)
5948                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5949         else
5950                 ret_constr.data = NULL;
5951         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5952         for (size_t l = 0; l < ret_constr.datalen; l++) {
5953                 uint32_t ret_conv_63 = ret_vals[l];
5954                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
5955                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
5956                 ret_constr.data[l] = ret_conv_63_conv;
5957         }
5958         return ret_constr;
5959 }
5960 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
5961         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5962         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5963         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
5964         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
5965         LDKCVec_NodeAnnouncementZ ret_constr;
5966         ret_constr.datalen = *((uint32_t*)ret);
5967         if (ret_constr.datalen > 0)
5968                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5969         else
5970                 ret_constr.data = NULL;
5971         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5972         for (size_t s = 0; s < ret_constr.datalen; s++) {
5973                 uint32_t ret_conv_18 = ret_vals[s];
5974                 LDKNodeAnnouncement ret_conv_18_conv;
5975                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
5976                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
5977                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
5978                 ret_constr.data[s] = ret_conv_18_conv;
5979         }
5980         return ret_constr;
5981 }
5982 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
5983         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5984         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5985         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5986         LDKInit init_var = *init;
5987         init_var = Init_clone(init);
5988         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5989         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5990         uint64_t init_ref = (uint64_t)init_var.inner;
5991         if (init_var.is_owned) {
5992                 init_ref |= 1;
5993         }
5994         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
5995 }
5996 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
5997         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5998         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5999         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6000         LDKReplyChannelRange msg_var = msg;
6001         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         uint64_t msg_ref = (uint64_t)msg_var.inner;
6004         if (msg_var.is_owned) {
6005                 msg_ref |= 1;
6006         }
6007         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6008         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6009         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6010         return ret_conv;
6011 }
6012 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6013         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6014         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6015         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6016         LDKReplyShortChannelIdsEnd msg_var = msg;
6017         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6018         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6019         uint64_t msg_ref = (uint64_t)msg_var.inner;
6020         if (msg_var.is_owned) {
6021                 msg_ref |= 1;
6022         }
6023         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6024         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6025         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6026         return ret_conv;
6027 }
6028 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6029         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6030         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6031         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6032         LDKQueryChannelRange msg_var = msg;
6033         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6034         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6035         uint64_t msg_ref = (uint64_t)msg_var.inner;
6036         if (msg_var.is_owned) {
6037                 msg_ref |= 1;
6038         }
6039         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6040         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6041         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6042         return ret_conv;
6043 }
6044 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6045         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6046         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6047         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6048         LDKQueryShortChannelIds msg_var = msg;
6049         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6050         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6051         uint64_t msg_ref = (uint64_t)msg_var.inner;
6052         if (msg_var.is_owned) {
6053                 msg_ref |= 1;
6054         }
6055         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6056         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6057         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6058         return ret_conv;
6059 }
6060 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
6061         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6062         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6063         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6064         return (void*) this_arg;
6065 }
6066 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6067         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6068         atomic_init(&calls->refcnt, 1);
6069         //TODO: Assign calls->o from o
6070
6071         LDKRoutingMessageHandler ret = {
6072                 .this_arg = (void*) calls,
6073                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6074                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6075                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6076                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
6077                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6078                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6079                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6080                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6081                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6082                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6083                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6084                 .free = LDKRoutingMessageHandler_JCalls_free,
6085                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6086         };
6087         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6088         return ret;
6089 }
6090 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6091         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6092         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6093         return (long)res_ptr;
6094 }
6095 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6096         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6097         LDKNodeAnnouncement msg_conv;
6098         msg_conv.inner = (void*)(msg & (~1));
6099         msg_conv.is_owned = false;
6100         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6101         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6102         return (uint64_t)ret_conv;
6103 }
6104
6105 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6106         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6107         LDKChannelAnnouncement msg_conv;
6108         msg_conv.inner = (void*)(msg & (~1));
6109         msg_conv.is_owned = false;
6110         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6111         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6112         return (uint64_t)ret_conv;
6113 }
6114
6115 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6116         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6117         LDKChannelUpdate msg_conv;
6118         msg_conv.inner = (void*)(msg & (~1));
6119         msg_conv.is_owned = false;
6120         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6121         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6122         return (uint64_t)ret_conv;
6123 }
6124
6125 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
6126         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6127         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
6128         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
6129 }
6130
6131 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6132         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6133         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6134         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6135         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6136         for (size_t l = 0; l < ret_var.datalen; l++) {
6137                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6138                 *ret_conv_63_ref = ret_var.data[l];
6139                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
6140         }
6141         FREE(ret_var.data);
6142         return ret_arr;
6143 }
6144
6145 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6146         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6147         LDKPublicKey starting_point_ref;
6148         CHECK(*((uint32_t*)starting_point) == 33);
6149         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6150         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6151         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6152         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6153         for (size_t s = 0; s < ret_var.datalen; s++) {
6154                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6155                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6156                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6157                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6158                 if (ret_conv_18_var.is_owned) {
6159                         ret_conv_18_ref |= 1;
6160                 }
6161                 ret_arr_ptr[s] = ret_conv_18_ref;
6162         }
6163         FREE(ret_var.data);
6164         return ret_arr;
6165 }
6166
6167 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6168         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6169         LDKPublicKey their_node_id_ref;
6170         CHECK(*((uint32_t*)their_node_id) == 33);
6171         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6172         LDKInit init_conv;
6173         init_conv.inner = (void*)(init & (~1));
6174         init_conv.is_owned = false;
6175         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6176 }
6177
6178 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6179         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6180         LDKPublicKey their_node_id_ref;
6181         CHECK(*((uint32_t*)their_node_id) == 33);
6182         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6183         LDKReplyChannelRange msg_conv;
6184         msg_conv.inner = (void*)(msg & (~1));
6185         msg_conv.is_owned = (msg & 1) || (msg == 0);
6186         msg_conv = ReplyChannelRange_clone(&msg_conv);
6187         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6188         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6189         return (uint64_t)ret_conv;
6190 }
6191
6192 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) {
6193         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6194         LDKPublicKey their_node_id_ref;
6195         CHECK(*((uint32_t*)their_node_id) == 33);
6196         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6197         LDKReplyShortChannelIdsEnd msg_conv;
6198         msg_conv.inner = (void*)(msg & (~1));
6199         msg_conv.is_owned = (msg & 1) || (msg == 0);
6200         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6201         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6202         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6203         return (uint64_t)ret_conv;
6204 }
6205
6206 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6207         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6208         LDKPublicKey their_node_id_ref;
6209         CHECK(*((uint32_t*)their_node_id) == 33);
6210         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6211         LDKQueryChannelRange msg_conv;
6212         msg_conv.inner = (void*)(msg & (~1));
6213         msg_conv.is_owned = (msg & 1) || (msg == 0);
6214         msg_conv = QueryChannelRange_clone(&msg_conv);
6215         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6216         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6217         return (uint64_t)ret_conv;
6218 }
6219
6220 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6221         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6222         LDKPublicKey their_node_id_ref;
6223         CHECK(*((uint32_t*)their_node_id) == 33);
6224         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6225         LDKQueryShortChannelIds msg_conv;
6226         msg_conv.inner = (void*)(msg & (~1));
6227         msg_conv.is_owned = (msg & 1) || (msg == 0);
6228         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6229         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6230         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6231         return (uint64_t)ret_conv;
6232 }
6233
6234 typedef struct LDKSocketDescriptor_JCalls {
6235         atomic_size_t refcnt;
6236         uint32_t send_data_meth;
6237         uint32_t disconnect_socket_meth;
6238         uint32_t eq_meth;
6239         uint32_t hash_meth;
6240 } LDKSocketDescriptor_JCalls;
6241 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
6242         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6243         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6244                 js_free(j_calls->send_data_meth);
6245                 js_free(j_calls->disconnect_socket_meth);
6246                 js_free(j_calls->eq_meth);
6247                 js_free(j_calls->hash_meth);
6248                 FREE(j_calls);
6249         }
6250 }
6251 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
6252         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6253         LDKu8slice data_var = data;
6254         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6255         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
6256         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
6257 }
6258 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
6259         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6260         js_invoke_function_0(j_calls->disconnect_socket_meth);
6261 }
6262 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
6263         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6264         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6265         *other_arg_clone = SocketDescriptor_clone(other_arg);
6266         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
6267 }
6268 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
6269         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6270         return js_invoke_function_0(j_calls->hash_meth);
6271 }
6272 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
6273         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
6274         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6275         return (void*) this_arg;
6276 }
6277 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
6278         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
6279         atomic_init(&calls->refcnt, 1);
6280         //TODO: Assign calls->o from o
6281
6282         LDKSocketDescriptor ret = {
6283                 .this_arg = (void*) calls,
6284                 .send_data = send_data_LDKSocketDescriptor_jcall,
6285                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
6286                 .eq = eq_LDKSocketDescriptor_jcall,
6287                 .hash = hash_LDKSocketDescriptor_jcall,
6288                 .clone = LDKSocketDescriptor_JCalls_clone,
6289                 .free = LDKSocketDescriptor_JCalls_free,
6290         };
6291         return ret;
6292 }
6293 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
6294         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
6295         *res_ptr = LDKSocketDescriptor_init(o);
6296         return (long)res_ptr;
6297 }
6298 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
6299         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6300         LDKu8slice data_ref;
6301         data_ref.datalen = *((uint32_t*)data);
6302         data_ref.data = (int8_t*)(data + 4);
6303         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
6304         return ret_val;
6305 }
6306
6307 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
6308         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6309         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
6310 }
6311
6312 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
6313         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
6314         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
6315         return ret_val;
6316 }
6317
6318 typedef struct LDKChannelManagerPersister_JCalls {
6319         atomic_size_t refcnt;
6320         uint32_t persist_manager_meth;
6321 } LDKChannelManagerPersister_JCalls;
6322 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
6323         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6324         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6325                 js_free(j_calls->persist_manager_meth);
6326                 FREE(j_calls);
6327         }
6328 }
6329 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
6330         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6331         LDKChannelManager channel_manager_var = *channel_manager;
6332         // Warning: we may need a move here but no clone is available for LDKChannelManager
6333         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6334         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6335         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
6336         if (channel_manager_var.is_owned) {
6337                 channel_manager_ref |= 1;
6338         }
6339         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
6340         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
6341         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
6342         return ret_conv;
6343 }
6344 static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
6345         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
6346         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6347         return (void*) this_arg;
6348 }
6349 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
6350         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
6351         atomic_init(&calls->refcnt, 1);
6352         //TODO: Assign calls->o from o
6353
6354         LDKChannelManagerPersister ret = {
6355                 .this_arg = (void*) calls,
6356                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
6357                 .free = LDKChannelManagerPersister_JCalls_free,
6358         };
6359         return ret;
6360 }
6361 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
6362         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
6363         *res_ptr = LDKChannelManagerPersister_init(o);
6364         return (long)res_ptr;
6365 }
6366 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
6367         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
6368         LDKChannelManager channel_manager_conv;
6369         channel_manager_conv.inner = (void*)(channel_manager & (~1));
6370         channel_manager_conv.is_owned = false;
6371         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6372         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
6373         return (uint64_t)ret_conv;
6374 }
6375
6376 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
6377         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
6378         switch(obj->tag) {
6379                 case LDKFallback_SegWitProgram: {
6380                         uint8_t version_val = obj->seg_wit_program.version._0;
6381                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
6382                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6383                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
6384                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
6385                 }
6386                 case LDKFallback_PubKeyHash: {
6387                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6388                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
6389                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
6390                 }
6391                 case LDKFallback_ScriptHash: {
6392                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
6393                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
6394                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
6395                 }
6396                 default: abort();
6397         }
6398 }
6399 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
6400         LDKStr ret_str = _ldk_get_compiled_version();
6401         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6402         return ret_conv;
6403 }
6404
6405 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
6406         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
6407         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6408         return ret_conv;
6409 }
6410
6411 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
6412         LDKTransaction _res_ref;
6413         _res_ref.datalen = *((uint32_t*)_res);
6414         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
6415         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
6416         _res_ref.data_is_owned = true;
6417         Transaction_free(_res_ref);
6418 }
6419
6420 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
6421         if ((_res & 1) != 0) return;
6422         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
6423         FREE((void*)_res);
6424         TxOut_free(_res_conv);
6425 }
6426
6427 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
6428         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
6429         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6430         *ret_ref = TxOut_clone(orig_conv);
6431         return (uint64_t)ret_ref;
6432 }
6433
6434 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
6435         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
6436         Str_free(dummy);
6437 }
6438
6439 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
6440         LDKSecretKey o_ref;
6441         CHECK(*((uint32_t*)o) == 32);
6442         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
6443         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6444         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
6445         return (uint64_t)ret_conv;
6446 }
6447
6448 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
6449         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6450         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
6451         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
6452         return (uint64_t)ret_conv;
6453 }
6454
6455 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
6456         if ((_res & 1) != 0) return;
6457         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
6458         FREE((void*)_res);
6459         CResult_SecretKeyErrorZ_free(_res_conv);
6460 }
6461
6462 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
6463         LDKPublicKey o_ref;
6464         CHECK(*((uint32_t*)o) == 33);
6465         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6466         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6467         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
6468         return (uint64_t)ret_conv;
6469 }
6470
6471 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
6472         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6473         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6474         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
6475         return (uint64_t)ret_conv;
6476 }
6477
6478 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
6479         if ((_res & 1) != 0) return;
6480         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
6481         FREE((void*)_res);
6482         CResult_PublicKeyErrorZ_free(_res_conv);
6483 }
6484
6485 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
6486         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
6487         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
6488         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
6489         return (uint64_t)ret_conv;
6490 }
6491
6492 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
6493         LDKTxCreationKeys o_conv;
6494         o_conv.inner = (void*)(o & (~1));
6495         o_conv.is_owned = (o & 1) || (o == 0);
6496         o_conv = TxCreationKeys_clone(&o_conv);
6497         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6498         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
6499         return (uint64_t)ret_conv;
6500 }
6501
6502 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
6503         LDKDecodeError e_conv;
6504         e_conv.inner = (void*)(e & (~1));
6505         e_conv.is_owned = (e & 1) || (e == 0);
6506         e_conv = DecodeError_clone(&e_conv);
6507         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6508         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
6509         return (uint64_t)ret_conv;
6510 }
6511
6512 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
6513         if ((_res & 1) != 0) return;
6514         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6515         FREE((void*)_res);
6516         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
6517 }
6518
6519 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
6520         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
6521         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
6522         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
6523         return (uint64_t)ret_conv;
6524 }
6525
6526 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
6527         LDKChannelPublicKeys o_conv;
6528         o_conv.inner = (void*)(o & (~1));
6529         o_conv.is_owned = (o & 1) || (o == 0);
6530         o_conv = ChannelPublicKeys_clone(&o_conv);
6531         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6532         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
6533         return (uint64_t)ret_conv;
6534 }
6535
6536 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
6537         LDKDecodeError e_conv;
6538         e_conv.inner = (void*)(e & (~1));
6539         e_conv.is_owned = (e & 1) || (e == 0);
6540         e_conv = DecodeError_clone(&e_conv);
6541         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6542         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
6543         return (uint64_t)ret_conv;
6544 }
6545
6546 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
6547         if ((_res & 1) != 0) return;
6548         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
6549         FREE((void*)_res);
6550         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
6551 }
6552
6553 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
6554         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
6555         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
6556         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
6557         return (uint64_t)ret_conv;
6558 }
6559
6560 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
6561         LDKTxCreationKeys o_conv;
6562         o_conv.inner = (void*)(o & (~1));
6563         o_conv.is_owned = (o & 1) || (o == 0);
6564         o_conv = TxCreationKeys_clone(&o_conv);
6565         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6566         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
6567         return (uint64_t)ret_conv;
6568 }
6569
6570 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
6571         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6572         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6573         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
6574         return (uint64_t)ret_conv;
6575 }
6576
6577 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
6578         if ((_res & 1) != 0) return;
6579         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
6580         FREE((void*)_res);
6581         CResult_TxCreationKeysErrorZ_free(_res_conv);
6582 }
6583
6584 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
6585         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
6586         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
6587         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
6588         return (uint64_t)ret_conv;
6589 }
6590
6591 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
6592         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6593         *ret_copy = COption_u32Z_some(o);
6594         uint64_t ret_ref = (uint64_t)ret_copy;
6595         return ret_ref;
6596 }
6597
6598 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
6599         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6600         *ret_copy = COption_u32Z_none();
6601         uint64_t ret_ref = (uint64_t)ret_copy;
6602         return ret_ref;
6603 }
6604
6605 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
6606         if ((_res & 1) != 0) return;
6607         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
6608         FREE((void*)_res);
6609         COption_u32Z_free(_res_conv);
6610 }
6611
6612 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
6613         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
6614         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
6615         *ret_copy = COption_u32Z_clone(orig_conv);
6616         uint64_t ret_ref = (uint64_t)ret_copy;
6617         return ret_ref;
6618 }
6619
6620 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
6621         LDKHTLCOutputInCommitment o_conv;
6622         o_conv.inner = (void*)(o & (~1));
6623         o_conv.is_owned = (o & 1) || (o == 0);
6624         o_conv = HTLCOutputInCommitment_clone(&o_conv);
6625         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6626         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
6627         return (uint64_t)ret_conv;
6628 }
6629
6630 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
6631         LDKDecodeError e_conv;
6632         e_conv.inner = (void*)(e & (~1));
6633         e_conv.is_owned = (e & 1) || (e == 0);
6634         e_conv = DecodeError_clone(&e_conv);
6635         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6636         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
6637         return (uint64_t)ret_conv;
6638 }
6639
6640 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
6641         if ((_res & 1) != 0) return;
6642         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
6643         FREE((void*)_res);
6644         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
6645 }
6646
6647 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
6648         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
6649         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
6650         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
6651         return (uint64_t)ret_conv;
6652 }
6653
6654 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6655         LDKCounterpartyChannelTransactionParameters o_conv;
6656         o_conv.inner = (void*)(o & (~1));
6657         o_conv.is_owned = (o & 1) || (o == 0);
6658         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
6659         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6660         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6661         return (uint64_t)ret_conv;
6662 }
6663
6664 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6665         LDKDecodeError e_conv;
6666         e_conv.inner = (void*)(e & (~1));
6667         e_conv.is_owned = (e & 1) || (e == 0);
6668         e_conv = DecodeError_clone(&e_conv);
6669         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6670         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
6671         return (uint64_t)ret_conv;
6672 }
6673
6674 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6675         if ((_res & 1) != 0) return;
6676         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6677         FREE((void*)_res);
6678         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6679 }
6680
6681 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6682         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6683         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
6684         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6685         return (uint64_t)ret_conv;
6686 }
6687
6688 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
6689         LDKChannelTransactionParameters o_conv;
6690         o_conv.inner = (void*)(o & (~1));
6691         o_conv.is_owned = (o & 1) || (o == 0);
6692         o_conv = ChannelTransactionParameters_clone(&o_conv);
6693         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6694         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
6695         return (uint64_t)ret_conv;
6696 }
6697
6698 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
6699         LDKDecodeError e_conv;
6700         e_conv.inner = (void*)(e & (~1));
6701         e_conv.is_owned = (e & 1) || (e == 0);
6702         e_conv = DecodeError_clone(&e_conv);
6703         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6704         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
6705         return (uint64_t)ret_conv;
6706 }
6707
6708 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
6709         if ((_res & 1) != 0) return;
6710         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
6711         FREE((void*)_res);
6712         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
6713 }
6714
6715 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
6716         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
6717         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
6718         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
6719         return (uint64_t)ret_conv;
6720 }
6721
6722 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
6723         LDKCVec_SignatureZ _res_constr;
6724         _res_constr.datalen = *((uint32_t*)_res);
6725         if (_res_constr.datalen > 0)
6726                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6727         else
6728                 _res_constr.data = NULL;
6729         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6730         for (size_t m = 0; m < _res_constr.datalen; m++) {
6731                 int8_tArray _res_conv_12 = _res_vals[m];
6732                 LDKSignature _res_conv_12_ref;
6733                 CHECK(*((uint32_t*)_res_conv_12) == 64);
6734                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
6735                 _res_constr.data[m] = _res_conv_12_ref;
6736         }
6737         CVec_SignatureZ_free(_res_constr);
6738 }
6739
6740 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6741         LDKHolderCommitmentTransaction o_conv;
6742         o_conv.inner = (void*)(o & (~1));
6743         o_conv.is_owned = (o & 1) || (o == 0);
6744         o_conv = HolderCommitmentTransaction_clone(&o_conv);
6745         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6746         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
6747         return (uint64_t)ret_conv;
6748 }
6749
6750 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6751         LDKDecodeError e_conv;
6752         e_conv.inner = (void*)(e & (~1));
6753         e_conv.is_owned = (e & 1) || (e == 0);
6754         e_conv = DecodeError_clone(&e_conv);
6755         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6756         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
6757         return (uint64_t)ret_conv;
6758 }
6759
6760 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6761         if ((_res & 1) != 0) return;
6762         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6763         FREE((void*)_res);
6764         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
6765 }
6766
6767 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6768         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6769         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
6770         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6771         return (uint64_t)ret_conv;
6772 }
6773
6774 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6775         LDKBuiltCommitmentTransaction o_conv;
6776         o_conv.inner = (void*)(o & (~1));
6777         o_conv.is_owned = (o & 1) || (o == 0);
6778         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
6779         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6780         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
6781         return (uint64_t)ret_conv;
6782 }
6783
6784 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6785         LDKDecodeError e_conv;
6786         e_conv.inner = (void*)(e & (~1));
6787         e_conv.is_owned = (e & 1) || (e == 0);
6788         e_conv = DecodeError_clone(&e_conv);
6789         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6790         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
6791         return (uint64_t)ret_conv;
6792 }
6793
6794 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6795         if ((_res & 1) != 0) return;
6796         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6797         FREE((void*)_res);
6798         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
6799 }
6800
6801 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6802         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
6803         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
6804         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
6805         return (uint64_t)ret_conv;
6806 }
6807
6808 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
6809         LDKCommitmentTransaction o_conv;
6810         o_conv.inner = (void*)(o & (~1));
6811         o_conv.is_owned = (o & 1) || (o == 0);
6812         o_conv = CommitmentTransaction_clone(&o_conv);
6813         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6814         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
6815         return (uint64_t)ret_conv;
6816 }
6817
6818 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
6819         LDKDecodeError e_conv;
6820         e_conv.inner = (void*)(e & (~1));
6821         e_conv.is_owned = (e & 1) || (e == 0);
6822         e_conv = DecodeError_clone(&e_conv);
6823         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6824         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
6825         return (uint64_t)ret_conv;
6826 }
6827
6828 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
6829         if ((_res & 1) != 0) return;
6830         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
6831         FREE((void*)_res);
6832         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
6833 }
6834
6835 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
6836         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
6837         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
6838         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
6839         return (uint64_t)ret_conv;
6840 }
6841
6842 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6843         LDKTrustedCommitmentTransaction o_conv;
6844         o_conv.inner = (void*)(o & (~1));
6845         o_conv.is_owned = (o & 1) || (o == 0);
6846         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
6847         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6848         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6849         return (uint64_t)ret_conv;
6850 }
6851
6852 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6853         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6854         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6855         return (uint64_t)ret_conv;
6856 }
6857
6858 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6859         if ((_res & 1) != 0) return;
6860         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
6861         FREE((void*)_res);
6862         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6863 }
6864
6865 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
6866         LDKCVec_SignatureZ o_constr;
6867         o_constr.datalen = *((uint32_t*)o);
6868         if (o_constr.datalen > 0)
6869                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
6870         else
6871                 o_constr.data = NULL;
6872         int8_tArray* o_vals = (int8_tArray*)(o + 4);
6873         for (size_t m = 0; m < o_constr.datalen; m++) {
6874                 int8_tArray o_conv_12 = o_vals[m];
6875                 LDKSignature o_conv_12_ref;
6876                 CHECK(*((uint32_t*)o_conv_12) == 64);
6877                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
6878                 o_constr.data[m] = o_conv_12_ref;
6879         }
6880         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6881         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
6882         return (uint64_t)ret_conv;
6883 }
6884
6885 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
6886         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6887         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
6888         return (uint64_t)ret_conv;
6889 }
6890
6891 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
6892         if ((_res & 1) != 0) return;
6893         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
6894         FREE((void*)_res);
6895         CResult_CVec_SignatureZNoneZ_free(_res_conv);
6896 }
6897
6898 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
6899         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
6900         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
6901         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
6902         return (uint64_t)ret_conv;
6903 }
6904
6905 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
6906         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6907         *ret_conv = CResult_NoneErrorZ_ok();
6908         return (uint64_t)ret_conv;
6909 }
6910
6911 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
6912         LDKIOError e_conv = LDKIOError_from_js(e);
6913         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6914         *ret_conv = CResult_NoneErrorZ_err(e_conv);
6915         return (uint64_t)ret_conv;
6916 }
6917
6918 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
6919         if ((_res & 1) != 0) return;
6920         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
6921         FREE((void*)_res);
6922         CResult_NoneErrorZ_free(_res_conv);
6923 }
6924
6925 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
6926         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
6927         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
6928         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
6929         return (uint64_t)ret_conv;
6930 }
6931
6932 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
6933         LDKRouteHop o_conv;
6934         o_conv.inner = (void*)(o & (~1));
6935         o_conv.is_owned = (o & 1) || (o == 0);
6936         o_conv = RouteHop_clone(&o_conv);
6937         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6938         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
6939         return (uint64_t)ret_conv;
6940 }
6941
6942 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
6943         LDKDecodeError e_conv;
6944         e_conv.inner = (void*)(e & (~1));
6945         e_conv.is_owned = (e & 1) || (e == 0);
6946         e_conv = DecodeError_clone(&e_conv);
6947         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6948         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
6949         return (uint64_t)ret_conv;
6950 }
6951
6952 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
6953         if ((_res & 1) != 0) return;
6954         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
6955         FREE((void*)_res);
6956         CResult_RouteHopDecodeErrorZ_free(_res_conv);
6957 }
6958
6959 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
6960         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
6961         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
6962         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
6963         return (uint64_t)ret_conv;
6964 }
6965
6966 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6967         LDKCVec_RouteHopZ _res_constr;
6968         _res_constr.datalen = *((uint32_t*)_res);
6969         if (_res_constr.datalen > 0)
6970                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6971         else
6972                 _res_constr.data = NULL;
6973         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6974         for (size_t k = 0; k < _res_constr.datalen; k++) {
6975                 uint32_t _res_conv_10 = _res_vals[k];
6976                 LDKRouteHop _res_conv_10_conv;
6977                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
6978                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
6979                 _res_constr.data[k] = _res_conv_10_conv;
6980         }
6981         CVec_RouteHopZ_free(_res_constr);
6982 }
6983
6984 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
6985         LDKCVec_CVec_RouteHopZZ _res_constr;
6986         _res_constr.datalen = *((uint32_t*)_res);
6987         if (_res_constr.datalen > 0)
6988                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
6989         else
6990                 _res_constr.data = NULL;
6991         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
6992         for (size_t m = 0; m < _res_constr.datalen; m++) {
6993                 uint32_tArray _res_conv_12 = _res_vals[m];
6994                 LDKCVec_RouteHopZ _res_conv_12_constr;
6995                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
6996                 if (_res_conv_12_constr.datalen > 0)
6997                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6998                 else
6999                         _res_conv_12_constr.data = NULL;
7000                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7001                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7002                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7003                         LDKRouteHop _res_conv_12_conv_10_conv;
7004                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7005                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7006                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7007                 }
7008                 _res_constr.data[m] = _res_conv_12_constr;
7009         }
7010         CVec_CVec_RouteHopZZ_free(_res_constr);
7011 }
7012
7013 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7014         LDKRoute o_conv;
7015         o_conv.inner = (void*)(o & (~1));
7016         o_conv.is_owned = (o & 1) || (o == 0);
7017         o_conv = Route_clone(&o_conv);
7018         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7019         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7020         return (uint64_t)ret_conv;
7021 }
7022
7023 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7024         LDKDecodeError e_conv;
7025         e_conv.inner = (void*)(e & (~1));
7026         e_conv.is_owned = (e & 1) || (e == 0);
7027         e_conv = DecodeError_clone(&e_conv);
7028         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7029         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7030         return (uint64_t)ret_conv;
7031 }
7032
7033 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7034         if ((_res & 1) != 0) return;
7035         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7036         FREE((void*)_res);
7037         CResult_RouteDecodeErrorZ_free(_res_conv);
7038 }
7039
7040 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7041         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7042         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7043         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7044         return (uint64_t)ret_conv;
7045 }
7046
7047 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7048         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7049         *ret_copy = COption_u64Z_some(o);
7050         uint64_t ret_ref = (uint64_t)ret_copy;
7051         return ret_ref;
7052 }
7053
7054 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7055         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7056         *ret_copy = COption_u64Z_none();
7057         uint64_t ret_ref = (uint64_t)ret_copy;
7058         return ret_ref;
7059 }
7060
7061 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7062         if ((_res & 1) != 0) return;
7063         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7064         FREE((void*)_res);
7065         COption_u64Z_free(_res_conv);
7066 }
7067
7068 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7069         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7070         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7071         *ret_copy = COption_u64Z_clone(orig_conv);
7072         uint64_t ret_ref = (uint64_t)ret_copy;
7073         return ret_ref;
7074 }
7075
7076 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7077         LDKCVec_ChannelDetailsZ _res_constr;
7078         _res_constr.datalen = *((uint32_t*)_res);
7079         if (_res_constr.datalen > 0)
7080                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7081         else
7082                 _res_constr.data = NULL;
7083         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7084         for (size_t q = 0; q < _res_constr.datalen; q++) {
7085                 uint32_t _res_conv_16 = _res_vals[q];
7086                 LDKChannelDetails _res_conv_16_conv;
7087                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7088                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7089                 _res_constr.data[q] = _res_conv_16_conv;
7090         }
7091         CVec_ChannelDetailsZ_free(_res_constr);
7092 }
7093
7094 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7095         LDKCVec_RouteHintZ _res_constr;
7096         _res_constr.datalen = *((uint32_t*)_res);
7097         if (_res_constr.datalen > 0)
7098                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7099         else
7100                 _res_constr.data = NULL;
7101         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7102         for (size_t l = 0; l < _res_constr.datalen; l++) {
7103                 uint32_t _res_conv_11 = _res_vals[l];
7104                 LDKRouteHint _res_conv_11_conv;
7105                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7106                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7107                 _res_constr.data[l] = _res_conv_11_conv;
7108         }
7109         CVec_RouteHintZ_free(_res_constr);
7110 }
7111
7112 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7113         LDKRoute o_conv;
7114         o_conv.inner = (void*)(o & (~1));
7115         o_conv.is_owned = (o & 1) || (o == 0);
7116         o_conv = Route_clone(&o_conv);
7117         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7118         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7119         return (uint64_t)ret_conv;
7120 }
7121
7122 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7123         LDKLightningError e_conv;
7124         e_conv.inner = (void*)(e & (~1));
7125         e_conv.is_owned = (e & 1) || (e == 0);
7126         e_conv = LightningError_clone(&e_conv);
7127         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7128         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7129         return (uint64_t)ret_conv;
7130 }
7131
7132 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7133         if ((_res & 1) != 0) return;
7134         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7135         FREE((void*)_res);
7136         CResult_RouteLightningErrorZ_free(_res_conv);
7137 }
7138
7139 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7140         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7141         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7142         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7143         return (uint64_t)ret_conv;
7144 }
7145
7146 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
7147         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
7148         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7149         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
7150         return (uint64_t)ret_conv;
7151 }
7152
7153 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
7154         LDKAccessError e_conv = LDKAccessError_from_js(e);
7155         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7156         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
7157         return (uint64_t)ret_conv;
7158 }
7159
7160 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
7161         if ((_res & 1) != 0) return;
7162         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
7163         FREE((void*)_res);
7164         CResult_TxOutAccessErrorZ_free(_res_conv);
7165 }
7166
7167 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
7168         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
7169         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7170         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
7171         return (uint64_t)ret_conv;
7172 }
7173
7174 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
7175         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
7176         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7177         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
7178         return (uint64_t)ret_ref;
7179 }
7180
7181 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
7182         LDKTransaction b_ref;
7183         b_ref.datalen = *((uint32_t*)b);
7184         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
7185         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
7186         b_ref.data_is_owned = true;
7187         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7188         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
7189         return (uint64_t)ret_ref;
7190 }
7191
7192 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
7193         if ((_res & 1) != 0) return;
7194         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
7195         FREE((void*)_res);
7196         C2Tuple_usizeTransactionZ_free(_res_conv);
7197 }
7198
7199 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
7200         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
7201         _res_constr.datalen = *((uint32_t*)_res);
7202         if (_res_constr.datalen > 0)
7203                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7204         else
7205                 _res_constr.data = NULL;
7206         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7207         for (size_t e = 0; e < _res_constr.datalen; e++) {
7208                 uint32_t _res_conv_30 = _res_vals[e];
7209                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
7210                 FREE((void*)_res_conv_30);
7211                 _res_constr.data[e] = _res_conv_30_conv;
7212         }
7213         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
7214 }
7215
7216 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
7217         LDKCVec_TxidZ _res_constr;
7218         _res_constr.datalen = *((uint32_t*)_res);
7219         if (_res_constr.datalen > 0)
7220                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7221         else
7222                 _res_constr.data = NULL;
7223         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7224         for (size_t m = 0; m < _res_constr.datalen; m++) {
7225                 int8_tArray _res_conv_12 = _res_vals[m];
7226                 LDKThirtyTwoBytes _res_conv_12_ref;
7227                 CHECK(*((uint32_t*)_res_conv_12) == 32);
7228                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
7229                 _res_constr.data[m] = _res_conv_12_ref;
7230         }
7231         CVec_TxidZ_free(_res_constr);
7232 }
7233
7234 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
7235         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7236         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
7237         return (uint64_t)ret_conv;
7238 }
7239
7240 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
7241         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
7242         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7243         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
7244         return (uint64_t)ret_conv;
7245 }
7246
7247 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
7248         if ((_res & 1) != 0) return;
7249         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
7250         FREE((void*)_res);
7251         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
7252 }
7253
7254 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
7255         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
7256         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7257         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
7258         return (uint64_t)ret_conv;
7259 }
7260
7261 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
7262         LDKCVec_MonitorEventZ _res_constr;
7263         _res_constr.datalen = *((uint32_t*)_res);
7264         if (_res_constr.datalen > 0)
7265                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
7266         else
7267                 _res_constr.data = NULL;
7268         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7269         for (size_t o = 0; o < _res_constr.datalen; o++) {
7270                 uint32_t _res_conv_14 = _res_vals[o];
7271                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
7272                 FREE((void*)_res_conv_14);
7273                 _res_constr.data[o] = _res_conv_14_conv;
7274         }
7275         CVec_MonitorEventZ_free(_res_constr);
7276 }
7277
7278 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
7279         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
7280         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7281         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
7282         uint64_t ret_ref = (uint64_t)ret_copy;
7283         return ret_ref;
7284 }
7285
7286 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
7287         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7288         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
7289         uint64_t ret_ref = (uint64_t)ret_copy;
7290         return ret_ref;
7291 }
7292
7293 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
7294         if ((_res & 1) != 0) return;
7295         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
7296         FREE((void*)_res);
7297         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
7298 }
7299
7300 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
7301         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
7302         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7303         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
7304         uint64_t ret_ref = (uint64_t)ret_copy;
7305         return ret_ref;
7306 }
7307
7308 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
7309         LDKCVec_SpendableOutputDescriptorZ _res_constr;
7310         _res_constr.datalen = *((uint32_t*)_res);
7311         if (_res_constr.datalen > 0)
7312                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
7313         else
7314                 _res_constr.data = NULL;
7315         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7316         for (size_t b = 0; b < _res_constr.datalen; b++) {
7317                 uint32_t _res_conv_27 = _res_vals[b];
7318                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
7319                 FREE((void*)_res_conv_27);
7320                 _res_constr.data[b] = _res_conv_27_conv;
7321         }
7322         CVec_SpendableOutputDescriptorZ_free(_res_constr);
7323 }
7324
7325 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
7326         LDKCVec_MessageSendEventZ _res_constr;
7327         _res_constr.datalen = *((uint32_t*)_res);
7328         if (_res_constr.datalen > 0)
7329                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7330         else
7331                 _res_constr.data = NULL;
7332         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7333         for (size_t s = 0; s < _res_constr.datalen; s++) {
7334                 uint32_t _res_conv_18 = _res_vals[s];
7335                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
7336                 FREE((void*)_res_conv_18);
7337                 _res_constr.data[s] = _res_conv_18_conv;
7338         }
7339         CVec_MessageSendEventZ_free(_res_constr);
7340 }
7341
7342 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
7343         LDKInitFeatures o_conv;
7344         o_conv.inner = (void*)(o & (~1));
7345         o_conv.is_owned = (o & 1) || (o == 0);
7346         o_conv = InitFeatures_clone(&o_conv);
7347         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7348         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
7349         return (uint64_t)ret_conv;
7350 }
7351
7352 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
7353         LDKDecodeError e_conv;
7354         e_conv.inner = (void*)(e & (~1));
7355         e_conv.is_owned = (e & 1) || (e == 0);
7356         e_conv = DecodeError_clone(&e_conv);
7357         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
7358         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
7359         return (uint64_t)ret_conv;
7360 }
7361
7362 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
7363         if ((_res & 1) != 0) return;
7364         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7365         FREE((void*)_res);
7366         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
7367 }
7368
7369 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
7370         LDKNodeFeatures o_conv;
7371         o_conv.inner = (void*)(o & (~1));
7372         o_conv.is_owned = (o & 1) || (o == 0);
7373         o_conv = NodeFeatures_clone(&o_conv);
7374         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7375         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
7376         return (uint64_t)ret_conv;
7377 }
7378
7379 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
7380         LDKDecodeError e_conv;
7381         e_conv.inner = (void*)(e & (~1));
7382         e_conv.is_owned = (e & 1) || (e == 0);
7383         e_conv = DecodeError_clone(&e_conv);
7384         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
7385         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
7386         return (uint64_t)ret_conv;
7387 }
7388
7389 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
7390         if ((_res & 1) != 0) return;
7391         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7392         FREE((void*)_res);
7393         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
7394 }
7395
7396 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
7397         LDKChannelFeatures o_conv;
7398         o_conv.inner = (void*)(o & (~1));
7399         o_conv.is_owned = (o & 1) || (o == 0);
7400         o_conv = ChannelFeatures_clone(&o_conv);
7401         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7402         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
7403         return (uint64_t)ret_conv;
7404 }
7405
7406 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
7407         LDKDecodeError e_conv;
7408         e_conv.inner = (void*)(e & (~1));
7409         e_conv.is_owned = (e & 1) || (e == 0);
7410         e_conv = DecodeError_clone(&e_conv);
7411         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
7412         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
7413         return (uint64_t)ret_conv;
7414 }
7415
7416 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
7417         if ((_res & 1) != 0) return;
7418         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7419         FREE((void*)_res);
7420         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
7421 }
7422
7423 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
7424         LDKInvoiceFeatures o_conv;
7425         o_conv.inner = (void*)(o & (~1));
7426         o_conv.is_owned = (o & 1) || (o == 0);
7427         o_conv = InvoiceFeatures_clone(&o_conv);
7428         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7429         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
7430         return (uint64_t)ret_conv;
7431 }
7432
7433 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
7434         LDKDecodeError e_conv;
7435         e_conv.inner = (void*)(e & (~1));
7436         e_conv.is_owned = (e & 1) || (e == 0);
7437         e_conv = DecodeError_clone(&e_conv);
7438         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
7439         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
7440         return (uint64_t)ret_conv;
7441 }
7442
7443 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
7444         if ((_res & 1) != 0) return;
7445         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7446         FREE((void*)_res);
7447         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
7448 }
7449
7450 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7451         LDKDelayedPaymentOutputDescriptor o_conv;
7452         o_conv.inner = (void*)(o & (~1));
7453         o_conv.is_owned = (o & 1) || (o == 0);
7454         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
7455         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7456         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7457         return (uint64_t)ret_conv;
7458 }
7459
7460 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7461         LDKDecodeError e_conv;
7462         e_conv.inner = (void*)(e & (~1));
7463         e_conv.is_owned = (e & 1) || (e == 0);
7464         e_conv = DecodeError_clone(&e_conv);
7465         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7466         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7467         return (uint64_t)ret_conv;
7468 }
7469
7470 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7471         if ((_res & 1) != 0) return;
7472         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7473         FREE((void*)_res);
7474         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7475 }
7476
7477 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7478         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7479         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
7480         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7481         return (uint64_t)ret_conv;
7482 }
7483
7484 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7485         LDKStaticPaymentOutputDescriptor o_conv;
7486         o_conv.inner = (void*)(o & (~1));
7487         o_conv.is_owned = (o & 1) || (o == 0);
7488         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
7489         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7490         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
7491         return (uint64_t)ret_conv;
7492 }
7493
7494 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7495         LDKDecodeError e_conv;
7496         e_conv.inner = (void*)(e & (~1));
7497         e_conv.is_owned = (e & 1) || (e == 0);
7498         e_conv = DecodeError_clone(&e_conv);
7499         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7500         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
7501         return (uint64_t)ret_conv;
7502 }
7503
7504 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7505         if ((_res & 1) != 0) return;
7506         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7507         FREE((void*)_res);
7508         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
7509 }
7510
7511 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7512         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
7513         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
7514         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
7515         return (uint64_t)ret_conv;
7516 }
7517
7518 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7519         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7520         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7521         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7522         return (uint64_t)ret_conv;
7523 }
7524
7525 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7526         LDKDecodeError e_conv;
7527         e_conv.inner = (void*)(e & (~1));
7528         e_conv.is_owned = (e & 1) || (e == 0);
7529         e_conv = DecodeError_clone(&e_conv);
7530         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7531         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7532         return (uint64_t)ret_conv;
7533 }
7534
7535 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7536         if ((_res & 1) != 0) return;
7537         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7538         FREE((void*)_res);
7539         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7540 }
7541
7542 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7543         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7544         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7545         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7546         return (uint64_t)ret_conv;
7547 }
7548
7549 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7550         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7551         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7552         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7553         return (uint64_t)ret_ref;
7554 }
7555
7556 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7557         LDKSignature a_ref;
7558         CHECK(*((uint32_t*)a) == 64);
7559         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7560         LDKCVec_SignatureZ b_constr;
7561         b_constr.datalen = *((uint32_t*)b);
7562         if (b_constr.datalen > 0)
7563                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7564         else
7565                 b_constr.data = NULL;
7566         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7567         for (size_t m = 0; m < b_constr.datalen; m++) {
7568                 int8_tArray b_conv_12 = b_vals[m];
7569                 LDKSignature b_conv_12_ref;
7570                 CHECK(*((uint32_t*)b_conv_12) == 64);
7571                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7572                 b_constr.data[m] = b_conv_12_ref;
7573         }
7574         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7575         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7576         return (uint64_t)ret_ref;
7577 }
7578
7579 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7580         if ((_res & 1) != 0) return;
7581         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7582         FREE((void*)_res);
7583         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7584 }
7585
7586 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7587         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7588         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7589         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7590         return (uint64_t)ret_conv;
7591 }
7592
7593 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7594         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7595         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7596         return (uint64_t)ret_conv;
7597 }
7598
7599 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7600         if ((_res & 1) != 0) return;
7601         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7602         FREE((void*)_res);
7603         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7604 }
7605
7606 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7607         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7608         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7609         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7610         return (uint64_t)ret_conv;
7611 }
7612
7613 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7614         LDKSignature o_ref;
7615         CHECK(*((uint32_t*)o) == 64);
7616         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7617         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7618         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7619         return (uint64_t)ret_conv;
7620 }
7621
7622 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7623         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7624         *ret_conv = CResult_SignatureNoneZ_err();
7625         return (uint64_t)ret_conv;
7626 }
7627
7628 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7629         if ((_res & 1) != 0) return;
7630         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7631         FREE((void*)_res);
7632         CResult_SignatureNoneZ_free(_res_conv);
7633 }
7634
7635 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7636         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7637         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7638         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7639         return (uint64_t)ret_conv;
7640 }
7641
7642 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7643         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7644         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7645         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7646         return (uint64_t)ret_conv;
7647 }
7648
7649 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7650         LDKDecodeError e_conv;
7651         e_conv.inner = (void*)(e & (~1));
7652         e_conv.is_owned = (e & 1) || (e == 0);
7653         e_conv = DecodeError_clone(&e_conv);
7654         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7655         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7656         return (uint64_t)ret_conv;
7657 }
7658
7659 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7660         if ((_res & 1) != 0) return;
7661         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7662         FREE((void*)_res);
7663         CResult_SignDecodeErrorZ_free(_res_conv);
7664 }
7665
7666 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7667         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7668         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7669         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7670         return (uint64_t)ret_conv;
7671 }
7672
7673 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
7674         LDKCVec_u8Z _res_ref;
7675         _res_ref.datalen = *((uint32_t*)_res);
7676         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
7677         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7678         CVec_u8Z_free(_res_ref);
7679 }
7680
7681 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
7682         LDKRecoverableSignature arg_ref;
7683         CHECK(*((uint32_t*)arg) == 68);
7684         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
7685         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7686         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
7687         return (uint64_t)ret_conv;
7688 }
7689
7690 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
7691         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7692         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
7693         return (uint64_t)ret_conv;
7694 }
7695
7696 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
7697         if ((_res & 1) != 0) return;
7698         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
7699         FREE((void*)_res);
7700         CResult_RecoverableSignatureNoneZ_free(_res_conv);
7701 }
7702
7703 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
7704         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
7705         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7706         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
7707         return (uint64_t)ret_conv;
7708 }
7709
7710 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7711         LDKCVec_CVec_u8ZZ _res_constr;
7712         _res_constr.datalen = *((uint32_t*)_res);
7713         if (_res_constr.datalen > 0)
7714                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7715         else
7716                 _res_constr.data = NULL;
7717         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7718         for (size_t m = 0; m < _res_constr.datalen; m++) {
7719                 int8_tArray _res_conv_12 = _res_vals[m];
7720                 LDKCVec_u8Z _res_conv_12_ref;
7721                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7722                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7723                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7724                 _res_constr.data[m] = _res_conv_12_ref;
7725         }
7726         CVec_CVec_u8ZZ_free(_res_constr);
7727 }
7728
7729 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7730         LDKCVec_CVec_u8ZZ o_constr;
7731         o_constr.datalen = *((uint32_t*)o);
7732         if (o_constr.datalen > 0)
7733                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7734         else
7735                 o_constr.data = NULL;
7736         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7737         for (size_t m = 0; m < o_constr.datalen; m++) {
7738                 int8_tArray o_conv_12 = o_vals[m];
7739                 LDKCVec_u8Z o_conv_12_ref;
7740                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7741                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7742                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7743                 o_constr.data[m] = o_conv_12_ref;
7744         }
7745         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7746         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7747         return (uint64_t)ret_conv;
7748 }
7749
7750 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7751         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7752         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7753         return (uint64_t)ret_conv;
7754 }
7755
7756 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7757         if ((_res & 1) != 0) return;
7758         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7759         FREE((void*)_res);
7760         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7761 }
7762
7763 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7764         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7765         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7766         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7767         return (uint64_t)ret_conv;
7768 }
7769
7770 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7771         LDKInMemorySigner o_conv;
7772         o_conv.inner = (void*)(o & (~1));
7773         o_conv.is_owned = (o & 1) || (o == 0);
7774         o_conv = InMemorySigner_clone(&o_conv);
7775         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7776         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7777         return (uint64_t)ret_conv;
7778 }
7779
7780 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7781         LDKDecodeError e_conv;
7782         e_conv.inner = (void*)(e & (~1));
7783         e_conv.is_owned = (e & 1) || (e == 0);
7784         e_conv = DecodeError_clone(&e_conv);
7785         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7786         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7787         return (uint64_t)ret_conv;
7788 }
7789
7790 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7791         if ((_res & 1) != 0) return;
7792         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7793         FREE((void*)_res);
7794         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7795 }
7796
7797 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7798         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7799         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7800         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7801         return (uint64_t)ret_conv;
7802 }
7803
7804 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7805         LDKCVec_TxOutZ _res_constr;
7806         _res_constr.datalen = *((uint32_t*)_res);
7807         if (_res_constr.datalen > 0)
7808                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7809         else
7810                 _res_constr.data = NULL;
7811         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7812         for (size_t h = 0; h < _res_constr.datalen; h++) {
7813                 uint32_t _res_conv_7 = _res_vals[h];
7814                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7815                 FREE((void*)_res_conv_7);
7816                 _res_constr.data[h] = _res_conv_7_conv;
7817         }
7818         CVec_TxOutZ_free(_res_constr);
7819 }
7820
7821 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7822         LDKTransaction o_ref;
7823         o_ref.datalen = *((uint32_t*)o);
7824         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7825         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7826         o_ref.data_is_owned = true;
7827         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7828         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7829         return (uint64_t)ret_conv;
7830 }
7831
7832 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7833         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7834         *ret_conv = CResult_TransactionNoneZ_err();
7835         return (uint64_t)ret_conv;
7836 }
7837
7838 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7839         if ((_res & 1) != 0) return;
7840         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7841         FREE((void*)_res);
7842         CResult_TransactionNoneZ_free(_res_conv);
7843 }
7844
7845 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
7846         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
7847         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7848         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
7849         return (uint64_t)ret_conv;
7850 }
7851
7852 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
7853         LDKThirtyTwoBytes a_ref;
7854         CHECK(*((uint32_t*)a) == 32);
7855         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7856         LDKChannelMonitor b_conv;
7857         b_conv.inner = (void*)(b & (~1));
7858         b_conv.is_owned = (b & 1) || (b == 0);
7859         b_conv = ChannelMonitor_clone(&b_conv);
7860         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7861         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
7862         return (uint64_t)ret_ref;
7863 }
7864
7865 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
7866         if ((_res & 1) != 0) return;
7867         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
7868         FREE((void*)_res);
7869         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
7870 }
7871
7872 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
7873         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
7874         _res_constr.datalen = *((uint32_t*)_res);
7875         if (_res_constr.datalen > 0)
7876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7877         else
7878                 _res_constr.data = NULL;
7879         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7880         for (size_t m = 0; m < _res_constr.datalen; m++) {
7881                 uint32_t _res_conv_38 = _res_vals[m];
7882                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_38) & ~1);
7883                 FREE((void*)_res_conv_38);
7884                 _res_constr.data[m] = _res_conv_38_conv;
7885         }
7886         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
7887 }
7888
7889 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
7890         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
7891         o_constr.datalen = *((uint32_t*)o);
7892         if (o_constr.datalen > 0)
7893                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
7894         else
7895                 o_constr.data = NULL;
7896         uint32_t* o_vals = (uint32_t*)(o + 4);
7897         for (size_t m = 0; m < o_constr.datalen; m++) {
7898                 uint32_t o_conv_38 = o_vals[m];
7899                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_38_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_38) & ~1);
7900                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
7901                 o_constr.data[m] = o_conv_38_conv;
7902         }
7903         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7904         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
7905         return (uint64_t)ret_conv;
7906 }
7907
7908 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
7909         LDKIOError e_conv = LDKIOError_from_js(e);
7910         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
7911         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
7912         return (uint64_t)ret_conv;
7913 }
7914
7915 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
7916         if ((_res & 1) != 0) return;
7917         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
7918         FREE((void*)_res);
7919         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
7920 }
7921
7922 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
7923         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7924         *ret_conv = CResult_NoneAPIErrorZ_ok();
7925         return (uint64_t)ret_conv;
7926 }
7927
7928 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
7929         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
7930         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7931         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
7932         return (uint64_t)ret_conv;
7933 }
7934
7935 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
7936         if ((_res & 1) != 0) return;
7937         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
7938         FREE((void*)_res);
7939         CResult_NoneAPIErrorZ_free(_res_conv);
7940 }
7941
7942 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
7943         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
7944         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7945         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
7946         return (uint64_t)ret_conv;
7947 }
7948
7949 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
7950         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
7951         _res_constr.datalen = *((uint32_t*)_res);
7952         if (_res_constr.datalen > 0)
7953                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
7954         else
7955                 _res_constr.data = NULL;
7956         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7957         for (size_t w = 0; w < _res_constr.datalen; w++) {
7958                 uint32_t _res_conv_22 = _res_vals[w];
7959                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
7960                 FREE((void*)_res_conv_22);
7961                 _res_constr.data[w] = _res_conv_22_conv;
7962         }
7963         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
7964 }
7965
7966 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
7967         LDKCVec_APIErrorZ _res_constr;
7968         _res_constr.datalen = *((uint32_t*)_res);
7969         if (_res_constr.datalen > 0)
7970                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
7971         else
7972                 _res_constr.data = NULL;
7973         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7974         for (size_t k = 0; k < _res_constr.datalen; k++) {
7975                 uint32_t _res_conv_10 = _res_vals[k];
7976                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
7977                 FREE((void*)_res_conv_10);
7978                 _res_constr.data[k] = _res_conv_10_conv;
7979         }
7980         CVec_APIErrorZ_free(_res_constr);
7981 }
7982
7983 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
7984         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7985         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7986         return (uint64_t)ret_conv;
7987 }
7988
7989 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
7990         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
7991         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7992         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7993         return (uint64_t)ret_conv;
7994 }
7995
7996 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
7997         if ((_res & 1) != 0) return;
7998         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
7999         FREE((void*)_res);
8000         CResult_NonePaymentSendFailureZ_free(_res_conv);
8001 }
8002
8003 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
8004         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
8005         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8006         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
8007         return (uint64_t)ret_conv;
8008 }
8009
8010 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
8011         LDKCVec_NetAddressZ _res_constr;
8012         _res_constr.datalen = *((uint32_t*)_res);
8013         if (_res_constr.datalen > 0)
8014                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8015         else
8016                 _res_constr.data = NULL;
8017         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8018         for (size_t m = 0; m < _res_constr.datalen; m++) {
8019                 uint32_t _res_conv_12 = _res_vals[m];
8020                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
8021                 FREE((void*)_res_conv_12);
8022                 _res_constr.data[m] = _res_conv_12_conv;
8023         }
8024         CVec_NetAddressZ_free(_res_constr);
8025 }
8026
8027 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
8028         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
8029         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8030         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
8031         return (uint64_t)ret_ref;
8032 }
8033
8034 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
8035         LDKThirtyTwoBytes a_ref;
8036         CHECK(*((uint32_t*)a) == 32);
8037         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8038         LDKThirtyTwoBytes b_ref;
8039         CHECK(*((uint32_t*)b) == 32);
8040         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8041         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
8042         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
8043         return (uint64_t)ret_ref;
8044 }
8045
8046 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
8047         if ((_res & 1) != 0) return;
8048         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
8049         FREE((void*)_res);
8050         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
8051 }
8052
8053 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
8054         LDKThirtyTwoBytes o_ref;
8055         CHECK(*((uint32_t*)o) == 32);
8056         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
8057         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8058         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
8059         return (uint64_t)ret_conv;
8060 }
8061
8062 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
8063         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8064         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8065         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
8066         return (uint64_t)ret_conv;
8067 }
8068
8069 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
8070         if ((_res & 1) != 0) return;
8071         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
8072         FREE((void*)_res);
8073         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
8074 }
8075
8076 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
8077         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
8078         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
8079         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
8080         return (uint64_t)ret_conv;
8081 }
8082
8083 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
8084         LDKCVec_ChannelMonitorZ _res_constr;
8085         _res_constr.datalen = *((uint32_t*)_res);
8086         if (_res_constr.datalen > 0)
8087                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8088         else
8089                 _res_constr.data = NULL;
8090         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8091         for (size_t q = 0; q < _res_constr.datalen; q++) {
8092                 uint32_t _res_conv_16 = _res_vals[q];
8093                 LDKChannelMonitor _res_conv_16_conv;
8094                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8095                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8096                 _res_constr.data[q] = _res_conv_16_conv;
8097         }
8098         CVec_ChannelMonitorZ_free(_res_constr);
8099 }
8100
8101 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
8102         LDKThirtyTwoBytes a_ref;
8103         CHECK(*((uint32_t*)a) == 32);
8104         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8105         LDKChannelManager b_conv;
8106         b_conv.inner = (void*)(b & (~1));
8107         b_conv.is_owned = (b & 1) || (b == 0);
8108         // Warning: we need a move here but no clone is available for LDKChannelManager
8109         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
8110         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
8111         return (uint64_t)ret_ref;
8112 }
8113
8114 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
8115         if ((_res & 1) != 0) return;
8116         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
8117         FREE((void*)_res);
8118         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
8119 }
8120
8121 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
8122         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
8123         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8124         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
8125         return (uint64_t)ret_conv;
8126 }
8127
8128 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
8129         LDKDecodeError e_conv;
8130         e_conv.inner = (void*)(e & (~1));
8131         e_conv.is_owned = (e & 1) || (e == 0);
8132         e_conv = DecodeError_clone(&e_conv);
8133         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8134         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
8135         return (uint64_t)ret_conv;
8136 }
8137
8138 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
8139         if ((_res & 1) != 0) return;
8140         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8141         FREE((void*)_res);
8142         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
8143 }
8144
8145 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8146         LDKChannelConfig o_conv;
8147         o_conv.inner = (void*)(o & (~1));
8148         o_conv.is_owned = (o & 1) || (o == 0);
8149         o_conv = ChannelConfig_clone(&o_conv);
8150         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8151         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
8152         return (uint64_t)ret_conv;
8153 }
8154
8155 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
8156         LDKDecodeError e_conv;
8157         e_conv.inner = (void*)(e & (~1));
8158         e_conv.is_owned = (e & 1) || (e == 0);
8159         e_conv = DecodeError_clone(&e_conv);
8160         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8161         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
8162         return (uint64_t)ret_conv;
8163 }
8164
8165 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
8166         if ((_res & 1) != 0) return;
8167         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
8168         FREE((void*)_res);
8169         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
8170 }
8171
8172 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
8173         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
8174         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
8175         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
8176         return (uint64_t)ret_conv;
8177 }
8178
8179 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
8180         LDKOutPoint o_conv;
8181         o_conv.inner = (void*)(o & (~1));
8182         o_conv.is_owned = (o & 1) || (o == 0);
8183         o_conv = OutPoint_clone(&o_conv);
8184         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8185         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
8186         return (uint64_t)ret_conv;
8187 }
8188
8189 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
8190         LDKDecodeError e_conv;
8191         e_conv.inner = (void*)(e & (~1));
8192         e_conv.is_owned = (e & 1) || (e == 0);
8193         e_conv = DecodeError_clone(&e_conv);
8194         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8195         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
8196         return (uint64_t)ret_conv;
8197 }
8198
8199 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
8200         if ((_res & 1) != 0) return;
8201         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
8202         FREE((void*)_res);
8203         CResult_OutPointDecodeErrorZ_free(_res_conv);
8204 }
8205
8206 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
8207         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
8208         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
8209         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
8210         return (uint64_t)ret_conv;
8211 }
8212
8213 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
8214         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
8215         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8216         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
8217         return (uint64_t)ret_conv;
8218 }
8219
8220 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
8221         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8222         *ret_conv = CResult_SiPrefixNoneZ_err();
8223         return (uint64_t)ret_conv;
8224 }
8225
8226 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
8227         if ((_res & 1) != 0) return;
8228         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
8229         FREE((void*)_res);
8230         CResult_SiPrefixNoneZ_free(_res_conv);
8231 }
8232
8233 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
8234         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
8235         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
8236         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
8237         return (uint64_t)ret_conv;
8238 }
8239
8240 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
8241         LDKInvoice o_conv;
8242         o_conv.inner = (void*)(o & (~1));
8243         o_conv.is_owned = (o & 1) || (o == 0);
8244         o_conv = Invoice_clone(&o_conv);
8245         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8246         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
8247         return (uint64_t)ret_conv;
8248 }
8249
8250 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
8251         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8252         *ret_conv = CResult_InvoiceNoneZ_err();
8253         return (uint64_t)ret_conv;
8254 }
8255
8256 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
8257         if ((_res & 1) != 0) return;
8258         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
8259         FREE((void*)_res);
8260         CResult_InvoiceNoneZ_free(_res_conv);
8261 }
8262
8263 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
8264         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
8265         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
8266         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
8267         return (uint64_t)ret_conv;
8268 }
8269
8270 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
8271         LDKSignedRawInvoice o_conv;
8272         o_conv.inner = (void*)(o & (~1));
8273         o_conv.is_owned = (o & 1) || (o == 0);
8274         o_conv = SignedRawInvoice_clone(&o_conv);
8275         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8276         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
8277         return (uint64_t)ret_conv;
8278 }
8279
8280 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
8281         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8282         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
8283         return (uint64_t)ret_conv;
8284 }
8285
8286 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
8287         if ((_res & 1) != 0) return;
8288         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
8289         FREE((void*)_res);
8290         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
8291 }
8292
8293 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
8294         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
8295         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
8296         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
8297         return (uint64_t)ret_conv;
8298 }
8299
8300 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
8301         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
8302         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8303         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
8304         return (uint64_t)ret_ref;
8305 }
8306
8307 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
8308         LDKRawInvoice a_conv;
8309         a_conv.inner = (void*)(a & (~1));
8310         a_conv.is_owned = (a & 1) || (a == 0);
8311         a_conv = RawInvoice_clone(&a_conv);
8312         LDKThirtyTwoBytes b_ref;
8313         CHECK(*((uint32_t*)b) == 32);
8314         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
8315         LDKInvoiceSignature c_conv;
8316         c_conv.inner = (void*)(c & (~1));
8317         c_conv.is_owned = (c & 1) || (c == 0);
8318         c_conv = InvoiceSignature_clone(&c_conv);
8319         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
8320         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
8321         return (uint64_t)ret_ref;
8322 }
8323
8324 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
8325         if ((_res & 1) != 0) return;
8326         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
8327         FREE((void*)_res);
8328         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
8329 }
8330
8331 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
8332         LDKPayeePubKey o_conv;
8333         o_conv.inner = (void*)(o & (~1));
8334         o_conv.is_owned = (o & 1) || (o == 0);
8335         o_conv = PayeePubKey_clone(&o_conv);
8336         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8337         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
8338         return (uint64_t)ret_conv;
8339 }
8340
8341 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
8342         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8343         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8344         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
8345         return (uint64_t)ret_conv;
8346 }
8347
8348 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
8349         if ((_res & 1) != 0) return;
8350         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
8351         FREE((void*)_res);
8352         CResult_PayeePubKeyErrorZ_free(_res_conv);
8353 }
8354
8355 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
8356         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
8357         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
8358         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
8359         return (uint64_t)ret_conv;
8360 }
8361
8362 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
8363         LDKCVec_PrivateRouteZ _res_constr;
8364         _res_constr.datalen = *((uint32_t*)_res);
8365         if (_res_constr.datalen > 0)
8366                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
8367         else
8368                 _res_constr.data = NULL;
8369         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8370         for (size_t o = 0; o < _res_constr.datalen; o++) {
8371                 uint32_t _res_conv_14 = _res_vals[o];
8372                 LDKPrivateRoute _res_conv_14_conv;
8373                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
8374                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
8375                 _res_constr.data[o] = _res_conv_14_conv;
8376         }
8377         CVec_PrivateRouteZ_free(_res_constr);
8378 }
8379
8380 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
8381         LDKPositiveTimestamp o_conv;
8382         o_conv.inner = (void*)(o & (~1));
8383         o_conv.is_owned = (o & 1) || (o == 0);
8384         o_conv = PositiveTimestamp_clone(&o_conv);
8385         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8386         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
8387         return (uint64_t)ret_conv;
8388 }
8389
8390 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
8391         LDKCreationError e_conv = LDKCreationError_from_js(e);
8392         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8393         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
8394         return (uint64_t)ret_conv;
8395 }
8396
8397 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
8398         if ((_res & 1) != 0) return;
8399         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
8400         FREE((void*)_res);
8401         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
8402 }
8403
8404 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
8405         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
8406         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
8407         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
8408         return (uint64_t)ret_conv;
8409 }
8410
8411 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
8412         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8413         *ret_conv = CResult_NoneSemanticErrorZ_ok();
8414         return (uint64_t)ret_conv;
8415 }
8416
8417 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
8418         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8419         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8420         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
8421         return (uint64_t)ret_conv;
8422 }
8423
8424 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
8425         if ((_res & 1) != 0) return;
8426         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
8427         FREE((void*)_res);
8428         CResult_NoneSemanticErrorZ_free(_res_conv);
8429 }
8430
8431 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
8432         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
8433         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
8434         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
8435         return (uint64_t)ret_conv;
8436 }
8437
8438 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
8439         LDKInvoice o_conv;
8440         o_conv.inner = (void*)(o & (~1));
8441         o_conv.is_owned = (o & 1) || (o == 0);
8442         o_conv = Invoice_clone(&o_conv);
8443         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8444         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
8445         return (uint64_t)ret_conv;
8446 }
8447
8448 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
8449         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
8450         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8451         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
8452         return (uint64_t)ret_conv;
8453 }
8454
8455 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
8456         if ((_res & 1) != 0) return;
8457         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
8458         FREE((void*)_res);
8459         CResult_InvoiceSemanticErrorZ_free(_res_conv);
8460 }
8461
8462 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
8463         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
8464         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
8465         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
8466         return (uint64_t)ret_conv;
8467 }
8468
8469 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
8470         LDKDescription o_conv;
8471         o_conv.inner = (void*)(o & (~1));
8472         o_conv.is_owned = (o & 1) || (o == 0);
8473         o_conv = Description_clone(&o_conv);
8474         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8475         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
8476         return (uint64_t)ret_conv;
8477 }
8478
8479 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
8480         LDKCreationError e_conv = LDKCreationError_from_js(e);
8481         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8482         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
8483         return (uint64_t)ret_conv;
8484 }
8485
8486 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
8487         if ((_res & 1) != 0) return;
8488         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
8489         FREE((void*)_res);
8490         CResult_DescriptionCreationErrorZ_free(_res_conv);
8491 }
8492
8493 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
8494         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
8495         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
8496         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
8497         return (uint64_t)ret_conv;
8498 }
8499
8500 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
8501         LDKExpiryTime o_conv;
8502         o_conv.inner = (void*)(o & (~1));
8503         o_conv.is_owned = (o & 1) || (o == 0);
8504         o_conv = ExpiryTime_clone(&o_conv);
8505         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8506         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
8507         return (uint64_t)ret_conv;
8508 }
8509
8510 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
8511         LDKCreationError e_conv = LDKCreationError_from_js(e);
8512         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8513         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
8514         return (uint64_t)ret_conv;
8515 }
8516
8517 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
8518         if ((_res & 1) != 0) return;
8519         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
8520         FREE((void*)_res);
8521         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
8522 }
8523
8524 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
8525         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
8526         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
8527         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
8528         return (uint64_t)ret_conv;
8529 }
8530
8531 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
8532         LDKPrivateRoute o_conv;
8533         o_conv.inner = (void*)(o & (~1));
8534         o_conv.is_owned = (o & 1) || (o == 0);
8535         o_conv = PrivateRoute_clone(&o_conv);
8536         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8537         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
8538         return (uint64_t)ret_conv;
8539 }
8540
8541 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
8542         LDKCreationError e_conv = LDKCreationError_from_js(e);
8543         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8544         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
8545         return (uint64_t)ret_conv;
8546 }
8547
8548 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
8549         if ((_res & 1) != 0) return;
8550         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
8551         FREE((void*)_res);
8552         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
8553 }
8554
8555 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
8556         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
8557         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
8558         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
8559         return (uint64_t)ret_conv;
8560 }
8561
8562 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
8563         LDKStr o_conv = str_ref_to_owned_c(o);
8564         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8565         *ret_conv = CResult_StringErrorZ_ok(o_conv);
8566         return (uint64_t)ret_conv;
8567 }
8568
8569 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
8570         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8571         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
8572         *ret_conv = CResult_StringErrorZ_err(e_conv);
8573         return (uint64_t)ret_conv;
8574 }
8575
8576 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
8577         if ((_res & 1) != 0) return;
8578         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
8579         FREE((void*)_res);
8580         CResult_StringErrorZ_free(_res_conv);
8581 }
8582
8583 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
8584         LDKChannelMonitorUpdate o_conv;
8585         o_conv.inner = (void*)(o & (~1));
8586         o_conv.is_owned = (o & 1) || (o == 0);
8587         o_conv = ChannelMonitorUpdate_clone(&o_conv);
8588         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8589         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
8590         return (uint64_t)ret_conv;
8591 }
8592
8593 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
8594         LDKDecodeError e_conv;
8595         e_conv.inner = (void*)(e & (~1));
8596         e_conv.is_owned = (e & 1) || (e == 0);
8597         e_conv = DecodeError_clone(&e_conv);
8598         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8599         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
8600         return (uint64_t)ret_conv;
8601 }
8602
8603 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
8604         if ((_res & 1) != 0) return;
8605         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8606         FREE((void*)_res);
8607         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
8608 }
8609
8610 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
8611         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
8612         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
8613         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
8614         return (uint64_t)ret_conv;
8615 }
8616
8617 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
8618         LDKHTLCUpdate o_conv;
8619         o_conv.inner = (void*)(o & (~1));
8620         o_conv.is_owned = (o & 1) || (o == 0);
8621         o_conv = HTLCUpdate_clone(&o_conv);
8622         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8623         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
8624         return (uint64_t)ret_conv;
8625 }
8626
8627 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
8628         LDKDecodeError e_conv;
8629         e_conv.inner = (void*)(e & (~1));
8630         e_conv.is_owned = (e & 1) || (e == 0);
8631         e_conv = DecodeError_clone(&e_conv);
8632         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8633         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
8634         return (uint64_t)ret_conv;
8635 }
8636
8637 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
8638         if ((_res & 1) != 0) return;
8639         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8640         FREE((void*)_res);
8641         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
8642 }
8643
8644 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
8645         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
8646         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
8647         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
8648         return (uint64_t)ret_conv;
8649 }
8650
8651 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
8652         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8653         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
8654         return (uint64_t)ret_conv;
8655 }
8656
8657 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
8658         LDKMonitorUpdateError e_conv;
8659         e_conv.inner = (void*)(e & (~1));
8660         e_conv.is_owned = (e & 1) || (e == 0);
8661         e_conv = MonitorUpdateError_clone(&e_conv);
8662         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8663         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
8664         return (uint64_t)ret_conv;
8665 }
8666
8667 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
8668         if ((_res & 1) != 0) return;
8669         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
8670         FREE((void*)_res);
8671         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
8672 }
8673
8674 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
8675         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
8676         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
8677         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
8682         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
8683         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8684         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
8685         return (uint64_t)ret_ref;
8686 }
8687
8688 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
8689         LDKOutPoint a_conv;
8690         a_conv.inner = (void*)(a & (~1));
8691         a_conv.is_owned = (a & 1) || (a == 0);
8692         a_conv = OutPoint_clone(&a_conv);
8693         LDKCVec_u8Z b_ref;
8694         b_ref.datalen = *((uint32_t*)b);
8695         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8696         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8697         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
8698         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
8699         return (uint64_t)ret_ref;
8700 }
8701
8702 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
8703         if ((_res & 1) != 0) return;
8704         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
8705         FREE((void*)_res);
8706         C2Tuple_OutPointScriptZ_free(_res_conv);
8707 }
8708
8709 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
8710         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
8711         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8712         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
8713         return (uint64_t)ret_ref;
8714 }
8715
8716 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
8717         LDKCVec_u8Z b_ref;
8718         b_ref.datalen = *((uint32_t*)b);
8719         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
8720         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8721         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8722         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
8723         return (uint64_t)ret_ref;
8724 }
8725
8726 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
8727         if ((_res & 1) != 0) return;
8728         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
8729         FREE((void*)_res);
8730         C2Tuple_u32ScriptZ_free(_res_conv);
8731 }
8732
8733 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
8734         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
8735         _res_constr.datalen = *((uint32_t*)_res);
8736         if (_res_constr.datalen > 0)
8737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8738         else
8739                 _res_constr.data = NULL;
8740         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8741         for (size_t e = 0; e < _res_constr.datalen; e++) {
8742                 uint32_t _res_conv_30 = _res_vals[e];
8743                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
8744                 FREE((void*)_res_conv_30);
8745                 _res_constr.data[e] = _res_conv_30_conv;
8746         }
8747         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
8748 }
8749
8750 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
8751         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
8752         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8753         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
8754         return (uint64_t)ret_ref;
8755 }
8756
8757 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
8758         LDKThirtyTwoBytes a_ref;
8759         CHECK(*((uint32_t*)a) == 32);
8760         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8761         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
8762         b_constr.datalen = *((uint32_t*)b);
8763         if (b_constr.datalen > 0)
8764                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
8765         else
8766                 b_constr.data = NULL;
8767         uint32_t* b_vals = (uint32_t*)(b + 4);
8768         for (size_t e = 0; e < b_constr.datalen; e++) {
8769                 uint32_t b_conv_30 = b_vals[e];
8770                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
8771                 b_conv_30_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1));
8772                 b_constr.data[e] = b_conv_30_conv;
8773         }
8774         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
8775         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
8776         return (uint64_t)ret_ref;
8777 }
8778
8779 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
8780         if ((_res & 1) != 0) return;
8781         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
8782         FREE((void*)_res);
8783         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
8784 }
8785
8786 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
8787         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
8788         _res_constr.datalen = *((uint32_t*)_res);
8789         if (_res_constr.datalen > 0)
8790                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
8791         else
8792                 _res_constr.data = NULL;
8793         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8794         for (size_t c = 0; c < _res_constr.datalen; c++) {
8795                 uint32_t _res_conv_54 = _res_vals[c];
8796                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
8797                 FREE((void*)_res_conv_54);
8798                 _res_constr.data[c] = _res_conv_54_conv;
8799         }
8800         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
8801 }
8802
8803 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
8804         LDKCVec_EventZ _res_constr;
8805         _res_constr.datalen = *((uint32_t*)_res);
8806         if (_res_constr.datalen > 0)
8807                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
8808         else
8809                 _res_constr.data = NULL;
8810         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8811         for (size_t h = 0; h < _res_constr.datalen; h++) {
8812                 uint32_t _res_conv_7 = _res_vals[h];
8813                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
8814                 FREE((void*)_res_conv_7);
8815                 _res_constr.data[h] = _res_conv_7_conv;
8816         }
8817         CVec_EventZ_free(_res_constr);
8818 }
8819
8820 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
8821         LDKCVec_TransactionZ _res_constr;
8822         _res_constr.datalen = *((uint32_t*)_res);
8823         if (_res_constr.datalen > 0)
8824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
8825         else
8826                 _res_constr.data = NULL;
8827         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8828         for (size_t m = 0; m < _res_constr.datalen; m++) {
8829                 int8_tArray _res_conv_12 = _res_vals[m];
8830                 LDKTransaction _res_conv_12_ref;
8831                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8832                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
8833                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8834                 _res_conv_12_ref.data_is_owned = true;
8835                 _res_constr.data[m] = _res_conv_12_ref;
8836         }
8837         CVec_TransactionZ_free(_res_constr);
8838 }
8839
8840 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
8841         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
8842         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8843         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
8844         return (uint64_t)ret_ref;
8845 }
8846
8847 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
8848         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
8849         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8850         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
8851         return (uint64_t)ret_ref;
8852 }
8853
8854 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
8855         if ((_res & 1) != 0) return;
8856         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
8857         FREE((void*)_res);
8858         C2Tuple_u32TxOutZ_free(_res_conv);
8859 }
8860
8861 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
8862         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
8863         _res_constr.datalen = *((uint32_t*)_res);
8864         if (_res_constr.datalen > 0)
8865                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8866         else
8867                 _res_constr.data = NULL;
8868         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8869         for (size_t z = 0; z < _res_constr.datalen; z++) {
8870                 uint32_t _res_conv_25 = _res_vals[z];
8871                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
8872                 FREE((void*)_res_conv_25);
8873                 _res_constr.data[z] = _res_conv_25_conv;
8874         }
8875         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
8876 }
8877
8878 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
8879         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
8880         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8881         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
8882         return (uint64_t)ret_ref;
8883 }
8884
8885 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
8886         LDKThirtyTwoBytes a_ref;
8887         CHECK(*((uint32_t*)a) == 32);
8888         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8889         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
8890         b_constr.datalen = *((uint32_t*)b);
8891         if (b_constr.datalen > 0)
8892                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
8893         else
8894                 b_constr.data = NULL;
8895         uint32_t* b_vals = (uint32_t*)(b + 4);
8896         for (size_t z = 0; z < b_constr.datalen; z++) {
8897                 uint32_t b_conv_25 = b_vals[z];
8898                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
8899                 b_conv_25_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1));
8900                 b_constr.data[z] = b_conv_25_conv;
8901         }
8902         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
8903         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
8904         return (uint64_t)ret_ref;
8905 }
8906
8907 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
8908         if ((_res & 1) != 0) return;
8909         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
8910         FREE((void*)_res);
8911         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
8912 }
8913
8914 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
8915         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
8916         _res_constr.datalen = *((uint32_t*)_res);
8917         if (_res_constr.datalen > 0)
8918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
8919         else
8920                 _res_constr.data = NULL;
8921         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8922         for (size_t x = 0; x < _res_constr.datalen; x++) {
8923                 uint32_t _res_conv_49 = _res_vals[x];
8924                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
8925                 FREE((void*)_res_conv_49);
8926                 _res_constr.data[x] = _res_conv_49_conv;
8927         }
8928         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
8929 }
8930
8931 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
8932         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
8933         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8934         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
8935         return (uint64_t)ret_conv;
8936 }
8937
8938 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
8939         LDKDecodeError e_conv;
8940         e_conv.inner = (void*)(e & (~1));
8941         e_conv.is_owned = (e & 1) || (e == 0);
8942         e_conv = DecodeError_clone(&e_conv);
8943         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
8944         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
8945         return (uint64_t)ret_conv;
8946 }
8947
8948 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
8949         if ((_res & 1) != 0) return;
8950         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
8951         FREE((void*)_res);
8952         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
8953 }
8954
8955 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
8956         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8957         *ret_conv = CResult_boolLightningErrorZ_ok(o);
8958         return (uint64_t)ret_conv;
8959 }
8960
8961 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
8962         LDKLightningError e_conv;
8963         e_conv.inner = (void*)(e & (~1));
8964         e_conv.is_owned = (e & 1) || (e == 0);
8965         e_conv = LightningError_clone(&e_conv);
8966         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8967         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
8968         return (uint64_t)ret_conv;
8969 }
8970
8971 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
8972         if ((_res & 1) != 0) return;
8973         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
8974         FREE((void*)_res);
8975         CResult_boolLightningErrorZ_free(_res_conv);
8976 }
8977
8978 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
8979         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
8980         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8981         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
8982         return (uint64_t)ret_conv;
8983 }
8984
8985 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
8986         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
8987         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8988         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
8989         return (uint64_t)ret_ref;
8990 }
8991
8992 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
8993         LDKChannelAnnouncement a_conv;
8994         a_conv.inner = (void*)(a & (~1));
8995         a_conv.is_owned = (a & 1) || (a == 0);
8996         a_conv = ChannelAnnouncement_clone(&a_conv);
8997         LDKChannelUpdate b_conv;
8998         b_conv.inner = (void*)(b & (~1));
8999         b_conv.is_owned = (b & 1) || (b == 0);
9000         b_conv = ChannelUpdate_clone(&b_conv);
9001         LDKChannelUpdate c_conv;
9002         c_conv.inner = (void*)(c & (~1));
9003         c_conv.is_owned = (c & 1) || (c == 0);
9004         c_conv = ChannelUpdate_clone(&c_conv);
9005         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9006         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
9007         return (uint64_t)ret_ref;
9008 }
9009
9010 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
9011         if ((_res & 1) != 0) return;
9012         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
9013         FREE((void*)_res);
9014         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
9015 }
9016
9017 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
9018         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
9019         _res_constr.datalen = *((uint32_t*)_res);
9020         if (_res_constr.datalen > 0)
9021                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9022         else
9023                 _res_constr.data = NULL;
9024         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9025         for (size_t l = 0; l < _res_constr.datalen; l++) {
9026                 uint32_t _res_conv_63 = _res_vals[l];
9027                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
9028                 FREE((void*)_res_conv_63);
9029                 _res_constr.data[l] = _res_conv_63_conv;
9030         }
9031         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
9032 }
9033
9034 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
9035         LDKCVec_NodeAnnouncementZ _res_constr;
9036         _res_constr.datalen = *((uint32_t*)_res);
9037         if (_res_constr.datalen > 0)
9038                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9039         else
9040                 _res_constr.data = NULL;
9041         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9042         for (size_t s = 0; s < _res_constr.datalen; s++) {
9043                 uint32_t _res_conv_18 = _res_vals[s];
9044                 LDKNodeAnnouncement _res_conv_18_conv;
9045                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
9046                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
9047                 _res_constr.data[s] = _res_conv_18_conv;
9048         }
9049         CVec_NodeAnnouncementZ_free(_res_constr);
9050 }
9051
9052 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
9053         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9054         *ret_conv = CResult_NoneLightningErrorZ_ok();
9055         return (uint64_t)ret_conv;
9056 }
9057
9058 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
9059         LDKLightningError e_conv;
9060         e_conv.inner = (void*)(e & (~1));
9061         e_conv.is_owned = (e & 1) || (e == 0);
9062         e_conv = LightningError_clone(&e_conv);
9063         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9064         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
9065         return (uint64_t)ret_conv;
9066 }
9067
9068 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
9069         if ((_res & 1) != 0) return;
9070         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
9071         FREE((void*)_res);
9072         CResult_NoneLightningErrorZ_free(_res_conv);
9073 }
9074
9075 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
9076         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
9077         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9078         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
9079         return (uint64_t)ret_conv;
9080 }
9081
9082 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
9083         LDKCVec_PublicKeyZ _res_constr;
9084         _res_constr.datalen = *((uint32_t*)_res);
9085         if (_res_constr.datalen > 0)
9086                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
9087         else
9088                 _res_constr.data = NULL;
9089         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9090         for (size_t m = 0; m < _res_constr.datalen; m++) {
9091                 int8_tArray _res_conv_12 = _res_vals[m];
9092                 LDKPublicKey _res_conv_12_ref;
9093                 CHECK(*((uint32_t*)_res_conv_12) == 33);
9094                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
9095                 _res_constr.data[m] = _res_conv_12_ref;
9096         }
9097         CVec_PublicKeyZ_free(_res_constr);
9098 }
9099
9100 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
9101         LDKCVec_u8Z o_ref;
9102         o_ref.datalen = *((uint32_t*)o);
9103         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
9104         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9105         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9106         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
9107         return (uint64_t)ret_conv;
9108 }
9109
9110 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
9111         LDKPeerHandleError e_conv;
9112         e_conv.inner = (void*)(e & (~1));
9113         e_conv.is_owned = (e & 1) || (e == 0);
9114         e_conv = PeerHandleError_clone(&e_conv);
9115         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9116         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
9117         return (uint64_t)ret_conv;
9118 }
9119
9120 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
9121         if ((_res & 1) != 0) return;
9122         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9123         FREE((void*)_res);
9124         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
9125 }
9126
9127 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
9128         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
9129         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
9130         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
9131         return (uint64_t)ret_conv;
9132 }
9133
9134 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
9135         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9136         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
9137         return (uint64_t)ret_conv;
9138 }
9139
9140 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
9141         LDKPeerHandleError e_conv;
9142         e_conv.inner = (void*)(e & (~1));
9143         e_conv.is_owned = (e & 1) || (e == 0);
9144         e_conv = PeerHandleError_clone(&e_conv);
9145         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9146         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
9147         return (uint64_t)ret_conv;
9148 }
9149
9150 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
9151         if ((_res & 1) != 0) return;
9152         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9153         FREE((void*)_res);
9154         CResult_NonePeerHandleErrorZ_free(_res_conv);
9155 }
9156
9157 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
9158         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
9159         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
9160         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
9161         return (uint64_t)ret_conv;
9162 }
9163
9164 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
9165         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9166         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
9167         return (uint64_t)ret_conv;
9168 }
9169
9170 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
9171         LDKPeerHandleError e_conv;
9172         e_conv.inner = (void*)(e & (~1));
9173         e_conv.is_owned = (e & 1) || (e == 0);
9174         e_conv = PeerHandleError_clone(&e_conv);
9175         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9176         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
9177         return (uint64_t)ret_conv;
9178 }
9179
9180 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
9181         if ((_res & 1) != 0) return;
9182         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
9183         FREE((void*)_res);
9184         CResult_boolPeerHandleErrorZ_free(_res_conv);
9185 }
9186
9187 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
9188         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
9189         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
9190         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
9191         return (uint64_t)ret_conv;
9192 }
9193
9194 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
9195         LDKDirectionalChannelInfo o_conv;
9196         o_conv.inner = (void*)(o & (~1));
9197         o_conv.is_owned = (o & 1) || (o == 0);
9198         o_conv = DirectionalChannelInfo_clone(&o_conv);
9199         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9200         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
9201         return (uint64_t)ret_conv;
9202 }
9203
9204 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
9205         LDKDecodeError e_conv;
9206         e_conv.inner = (void*)(e & (~1));
9207         e_conv.is_owned = (e & 1) || (e == 0);
9208         e_conv = DecodeError_clone(&e_conv);
9209         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9210         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
9211         return (uint64_t)ret_conv;
9212 }
9213
9214 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
9215         if ((_res & 1) != 0) return;
9216         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9217         FREE((void*)_res);
9218         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
9219 }
9220
9221 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9222         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
9223         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
9224         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
9225         return (uint64_t)ret_conv;
9226 }
9227
9228 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
9229         LDKChannelInfo o_conv;
9230         o_conv.inner = (void*)(o & (~1));
9231         o_conv.is_owned = (o & 1) || (o == 0);
9232         o_conv = ChannelInfo_clone(&o_conv);
9233         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9234         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
9235         return (uint64_t)ret_conv;
9236 }
9237
9238 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
9239         LDKDecodeError e_conv;
9240         e_conv.inner = (void*)(e & (~1));
9241         e_conv.is_owned = (e & 1) || (e == 0);
9242         e_conv = DecodeError_clone(&e_conv);
9243         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9244         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
9245         return (uint64_t)ret_conv;
9246 }
9247
9248 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
9249         if ((_res & 1) != 0) return;
9250         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9251         FREE((void*)_res);
9252         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
9253 }
9254
9255 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
9256         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
9257         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
9258         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
9259         return (uint64_t)ret_conv;
9260 }
9261
9262 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
9263         LDKRoutingFees o_conv;
9264         o_conv.inner = (void*)(o & (~1));
9265         o_conv.is_owned = (o & 1) || (o == 0);
9266         o_conv = RoutingFees_clone(&o_conv);
9267         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9268         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
9269         return (uint64_t)ret_conv;
9270 }
9271
9272 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
9273         LDKDecodeError e_conv;
9274         e_conv.inner = (void*)(e & (~1));
9275         e_conv.is_owned = (e & 1) || (e == 0);
9276         e_conv = DecodeError_clone(&e_conv);
9277         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9278         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
9279         return (uint64_t)ret_conv;
9280 }
9281
9282 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
9283         if ((_res & 1) != 0) return;
9284         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9285         FREE((void*)_res);
9286         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
9287 }
9288
9289 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
9290         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
9291         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
9292         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
9293         return (uint64_t)ret_conv;
9294 }
9295
9296 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
9297         LDKNodeAnnouncementInfo o_conv;
9298         o_conv.inner = (void*)(o & (~1));
9299         o_conv.is_owned = (o & 1) || (o == 0);
9300         o_conv = NodeAnnouncementInfo_clone(&o_conv);
9301         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9302         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
9303         return (uint64_t)ret_conv;
9304 }
9305
9306 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
9307         LDKDecodeError e_conv;
9308         e_conv.inner = (void*)(e & (~1));
9309         e_conv.is_owned = (e & 1) || (e == 0);
9310         e_conv = DecodeError_clone(&e_conv);
9311         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9312         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
9313         return (uint64_t)ret_conv;
9314 }
9315
9316 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
9317         if ((_res & 1) != 0) return;
9318         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9319         FREE((void*)_res);
9320         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
9321 }
9322
9323 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
9324         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
9325         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
9326         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
9327         return (uint64_t)ret_conv;
9328 }
9329
9330 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
9331         LDKCVec_u64Z _res_constr;
9332         _res_constr.datalen = *((uint32_t*)_res);
9333         if (_res_constr.datalen > 0)
9334                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9335         else
9336                 _res_constr.data = NULL;
9337         int64_t* _res_vals = (int64_t*)(_res + 4);
9338         for (size_t i = 0; i < _res_constr.datalen; i++) {
9339                 int64_t _res_conv_8 = _res_vals[i];
9340                 _res_constr.data[i] = _res_conv_8;
9341         }
9342         CVec_u64Z_free(_res_constr);
9343 }
9344
9345 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
9346         LDKNodeInfo o_conv;
9347         o_conv.inner = (void*)(o & (~1));
9348         o_conv.is_owned = (o & 1) || (o == 0);
9349         o_conv = NodeInfo_clone(&o_conv);
9350         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9351         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
9352         return (uint64_t)ret_conv;
9353 }
9354
9355 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
9356         LDKDecodeError e_conv;
9357         e_conv.inner = (void*)(e & (~1));
9358         e_conv.is_owned = (e & 1) || (e == 0);
9359         e_conv = DecodeError_clone(&e_conv);
9360         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9361         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
9362         return (uint64_t)ret_conv;
9363 }
9364
9365 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
9366         if ((_res & 1) != 0) return;
9367         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
9368         FREE((void*)_res);
9369         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
9370 }
9371
9372 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
9373         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
9374         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
9375         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
9376         return (uint64_t)ret_conv;
9377 }
9378
9379 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
9380         LDKNetworkGraph o_conv;
9381         o_conv.inner = (void*)(o & (~1));
9382         o_conv.is_owned = (o & 1) || (o == 0);
9383         o_conv = NetworkGraph_clone(&o_conv);
9384         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9385         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
9386         return (uint64_t)ret_conv;
9387 }
9388
9389 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
9390         LDKDecodeError e_conv;
9391         e_conv.inner = (void*)(e & (~1));
9392         e_conv.is_owned = (e & 1) || (e == 0);
9393         e_conv = DecodeError_clone(&e_conv);
9394         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9395         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
9396         return (uint64_t)ret_conv;
9397 }
9398
9399 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
9400         if ((_res & 1) != 0) return;
9401         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
9402         FREE((void*)_res);
9403         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
9404 }
9405
9406 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
9407         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
9408         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
9409         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
9410         return (uint64_t)ret_conv;
9411 }
9412
9413 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
9414         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9415         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9416         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
9417         return (uint64_t)ret_conv;
9418 }
9419
9420 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
9421         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9422         *ret_conv = CResult_NetAddressu8Z_err(e);
9423         return (uint64_t)ret_conv;
9424 }
9425
9426 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
9427         if ((_res & 1) != 0) return;
9428         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
9429         FREE((void*)_res);
9430         CResult_NetAddressu8Z_free(_res_conv);
9431 }
9432
9433 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
9434         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
9435         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
9436         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
9437         return (uint64_t)ret_conv;
9438 }
9439
9440 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
9441         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
9442         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9443         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
9444         return (uint64_t)ret_conv;
9445 }
9446
9447 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
9448         LDKDecodeError e_conv;
9449         e_conv.inner = (void*)(e & (~1));
9450         e_conv.is_owned = (e & 1) || (e == 0);
9451         e_conv = DecodeError_clone(&e_conv);
9452         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9453         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
9454         return (uint64_t)ret_conv;
9455 }
9456
9457 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
9458         if ((_res & 1) != 0) return;
9459         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9460         FREE((void*)_res);
9461         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
9462 }
9463
9464 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
9465         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
9466         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9467         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
9468         return (uint64_t)ret_conv;
9469 }
9470
9471 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
9472         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
9473         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9474         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
9475         return (uint64_t)ret_conv;
9476 }
9477
9478 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
9479         LDKDecodeError e_conv;
9480         e_conv.inner = (void*)(e & (~1));
9481         e_conv.is_owned = (e & 1) || (e == 0);
9482         e_conv = DecodeError_clone(&e_conv);
9483         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9484         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
9485         return (uint64_t)ret_conv;
9486 }
9487
9488 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
9489         if ((_res & 1) != 0) return;
9490         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
9491         FREE((void*)_res);
9492         CResult_NetAddressDecodeErrorZ_free(_res_conv);
9493 }
9494
9495 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
9496         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
9497         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
9498         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
9499         return (uint64_t)ret_conv;
9500 }
9501
9502 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
9503         LDKCVec_UpdateAddHTLCZ _res_constr;
9504         _res_constr.datalen = *((uint32_t*)_res);
9505         if (_res_constr.datalen > 0)
9506                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
9507         else
9508                 _res_constr.data = NULL;
9509         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9510         for (size_t p = 0; p < _res_constr.datalen; p++) {
9511                 uint32_t _res_conv_15 = _res_vals[p];
9512                 LDKUpdateAddHTLC _res_conv_15_conv;
9513                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
9514                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
9515                 _res_constr.data[p] = _res_conv_15_conv;
9516         }
9517         CVec_UpdateAddHTLCZ_free(_res_constr);
9518 }
9519
9520 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
9521         LDKCVec_UpdateFulfillHTLCZ _res_constr;
9522         _res_constr.datalen = *((uint32_t*)_res);
9523         if (_res_constr.datalen > 0)
9524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
9525         else
9526                 _res_constr.data = NULL;
9527         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9528         for (size_t t = 0; t < _res_constr.datalen; t++) {
9529                 uint32_t _res_conv_19 = _res_vals[t];
9530                 LDKUpdateFulfillHTLC _res_conv_19_conv;
9531                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
9532                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
9533                 _res_constr.data[t] = _res_conv_19_conv;
9534         }
9535         CVec_UpdateFulfillHTLCZ_free(_res_constr);
9536 }
9537
9538 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
9539         LDKCVec_UpdateFailHTLCZ _res_constr;
9540         _res_constr.datalen = *((uint32_t*)_res);
9541         if (_res_constr.datalen > 0)
9542                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
9543         else
9544                 _res_constr.data = NULL;
9545         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9546         for (size_t q = 0; q < _res_constr.datalen; q++) {
9547                 uint32_t _res_conv_16 = _res_vals[q];
9548                 LDKUpdateFailHTLC _res_conv_16_conv;
9549                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9550                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9551                 _res_constr.data[q] = _res_conv_16_conv;
9552         }
9553         CVec_UpdateFailHTLCZ_free(_res_constr);
9554 }
9555
9556 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
9557         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
9558         _res_constr.datalen = *((uint32_t*)_res);
9559         if (_res_constr.datalen > 0)
9560                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
9561         else
9562                 _res_constr.data = NULL;
9563         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9564         for (size_t z = 0; z < _res_constr.datalen; z++) {
9565                 uint32_t _res_conv_25 = _res_vals[z];
9566                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
9567                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
9568                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
9569                 _res_constr.data[z] = _res_conv_25_conv;
9570         }
9571         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
9572 }
9573
9574 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
9575         LDKAcceptChannel o_conv;
9576         o_conv.inner = (void*)(o & (~1));
9577         o_conv.is_owned = (o & 1) || (o == 0);
9578         o_conv = AcceptChannel_clone(&o_conv);
9579         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9580         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
9581         return (uint64_t)ret_conv;
9582 }
9583
9584 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
9585         LDKDecodeError e_conv;
9586         e_conv.inner = (void*)(e & (~1));
9587         e_conv.is_owned = (e & 1) || (e == 0);
9588         e_conv = DecodeError_clone(&e_conv);
9589         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9590         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
9591         return (uint64_t)ret_conv;
9592 }
9593
9594 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
9595         if ((_res & 1) != 0) return;
9596         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9597         FREE((void*)_res);
9598         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
9599 }
9600
9601 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
9602         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
9603         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
9604         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
9605         return (uint64_t)ret_conv;
9606 }
9607
9608 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
9609         LDKAnnouncementSignatures o_conv;
9610         o_conv.inner = (void*)(o & (~1));
9611         o_conv.is_owned = (o & 1) || (o == 0);
9612         o_conv = AnnouncementSignatures_clone(&o_conv);
9613         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9614         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
9615         return (uint64_t)ret_conv;
9616 }
9617
9618 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
9619         LDKDecodeError e_conv;
9620         e_conv.inner = (void*)(e & (~1));
9621         e_conv.is_owned = (e & 1) || (e == 0);
9622         e_conv = DecodeError_clone(&e_conv);
9623         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9624         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
9625         return (uint64_t)ret_conv;
9626 }
9627
9628 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
9629         if ((_res & 1) != 0) return;
9630         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9631         FREE((void*)_res);
9632         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
9633 }
9634
9635 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
9636         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
9637         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
9638         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
9639         return (uint64_t)ret_conv;
9640 }
9641
9642 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
9643         LDKChannelReestablish o_conv;
9644         o_conv.inner = (void*)(o & (~1));
9645         o_conv.is_owned = (o & 1) || (o == 0);
9646         o_conv = ChannelReestablish_clone(&o_conv);
9647         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9648         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
9649         return (uint64_t)ret_conv;
9650 }
9651
9652 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
9653         LDKDecodeError e_conv;
9654         e_conv.inner = (void*)(e & (~1));
9655         e_conv.is_owned = (e & 1) || (e == 0);
9656         e_conv = DecodeError_clone(&e_conv);
9657         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9658         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
9659         return (uint64_t)ret_conv;
9660 }
9661
9662 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
9663         if ((_res & 1) != 0) return;
9664         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
9665         FREE((void*)_res);
9666         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
9667 }
9668
9669 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
9670         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
9671         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
9672         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
9677         LDKClosingSigned o_conv;
9678         o_conv.inner = (void*)(o & (~1));
9679         o_conv.is_owned = (o & 1) || (o == 0);
9680         o_conv = ClosingSigned_clone(&o_conv);
9681         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9682         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
9683         return (uint64_t)ret_conv;
9684 }
9685
9686 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
9687         LDKDecodeError e_conv;
9688         e_conv.inner = (void*)(e & (~1));
9689         e_conv.is_owned = (e & 1) || (e == 0);
9690         e_conv = DecodeError_clone(&e_conv);
9691         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9692         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
9693         return (uint64_t)ret_conv;
9694 }
9695
9696 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
9697         if ((_res & 1) != 0) return;
9698         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9699         FREE((void*)_res);
9700         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
9701 }
9702
9703 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
9704         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
9705         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
9706         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
9707         return (uint64_t)ret_conv;
9708 }
9709
9710 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
9711         LDKCommitmentSigned o_conv;
9712         o_conv.inner = (void*)(o & (~1));
9713         o_conv.is_owned = (o & 1) || (o == 0);
9714         o_conv = CommitmentSigned_clone(&o_conv);
9715         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9716         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
9717         return (uint64_t)ret_conv;
9718 }
9719
9720 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
9721         LDKDecodeError e_conv;
9722         e_conv.inner = (void*)(e & (~1));
9723         e_conv.is_owned = (e & 1) || (e == 0);
9724         e_conv = DecodeError_clone(&e_conv);
9725         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9726         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
9727         return (uint64_t)ret_conv;
9728 }
9729
9730 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
9731         if ((_res & 1) != 0) return;
9732         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9733         FREE((void*)_res);
9734         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
9735 }
9736
9737 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
9738         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
9739         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
9740         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
9741         return (uint64_t)ret_conv;
9742 }
9743
9744 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
9745         LDKFundingCreated o_conv;
9746         o_conv.inner = (void*)(o & (~1));
9747         o_conv.is_owned = (o & 1) || (o == 0);
9748         o_conv = FundingCreated_clone(&o_conv);
9749         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9750         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
9751         return (uint64_t)ret_conv;
9752 }
9753
9754 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
9755         LDKDecodeError e_conv;
9756         e_conv.inner = (void*)(e & (~1));
9757         e_conv.is_owned = (e & 1) || (e == 0);
9758         e_conv = DecodeError_clone(&e_conv);
9759         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9760         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
9761         return (uint64_t)ret_conv;
9762 }
9763
9764 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
9765         if ((_res & 1) != 0) return;
9766         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9767         FREE((void*)_res);
9768         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
9769 }
9770
9771 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
9772         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
9773         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
9774         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
9775         return (uint64_t)ret_conv;
9776 }
9777
9778 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
9779         LDKFundingSigned o_conv;
9780         o_conv.inner = (void*)(o & (~1));
9781         o_conv.is_owned = (o & 1) || (o == 0);
9782         o_conv = FundingSigned_clone(&o_conv);
9783         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9784         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
9785         return (uint64_t)ret_conv;
9786 }
9787
9788 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
9789         LDKDecodeError e_conv;
9790         e_conv.inner = (void*)(e & (~1));
9791         e_conv.is_owned = (e & 1) || (e == 0);
9792         e_conv = DecodeError_clone(&e_conv);
9793         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9794         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
9795         return (uint64_t)ret_conv;
9796 }
9797
9798 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
9799         if ((_res & 1) != 0) return;
9800         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9801         FREE((void*)_res);
9802         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
9803 }
9804
9805 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
9806         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
9807         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
9808         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
9809         return (uint64_t)ret_conv;
9810 }
9811
9812 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
9813         LDKFundingLocked o_conv;
9814         o_conv.inner = (void*)(o & (~1));
9815         o_conv.is_owned = (o & 1) || (o == 0);
9816         o_conv = FundingLocked_clone(&o_conv);
9817         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9818         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
9819         return (uint64_t)ret_conv;
9820 }
9821
9822 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
9823         LDKDecodeError e_conv;
9824         e_conv.inner = (void*)(e & (~1));
9825         e_conv.is_owned = (e & 1) || (e == 0);
9826         e_conv = DecodeError_clone(&e_conv);
9827         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9828         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
9829         return (uint64_t)ret_conv;
9830 }
9831
9832 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
9833         if ((_res & 1) != 0) return;
9834         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
9835         FREE((void*)_res);
9836         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
9837 }
9838
9839 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
9840         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
9841         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
9842         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
9843         return (uint64_t)ret_conv;
9844 }
9845
9846 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
9847         LDKInit o_conv;
9848         o_conv.inner = (void*)(o & (~1));
9849         o_conv.is_owned = (o & 1) || (o == 0);
9850         o_conv = Init_clone(&o_conv);
9851         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9852         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
9853         return (uint64_t)ret_conv;
9854 }
9855
9856 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
9857         LDKDecodeError e_conv;
9858         e_conv.inner = (void*)(e & (~1));
9859         e_conv.is_owned = (e & 1) || (e == 0);
9860         e_conv = DecodeError_clone(&e_conv);
9861         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9862         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
9863         return (uint64_t)ret_conv;
9864 }
9865
9866 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
9867         if ((_res & 1) != 0) return;
9868         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
9869         FREE((void*)_res);
9870         CResult_InitDecodeErrorZ_free(_res_conv);
9871 }
9872
9873 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
9874         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
9875         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
9876         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
9877         return (uint64_t)ret_conv;
9878 }
9879
9880 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
9881         LDKOpenChannel o_conv;
9882         o_conv.inner = (void*)(o & (~1));
9883         o_conv.is_owned = (o & 1) || (o == 0);
9884         o_conv = OpenChannel_clone(&o_conv);
9885         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9886         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
9887         return (uint64_t)ret_conv;
9888 }
9889
9890 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
9891         LDKDecodeError e_conv;
9892         e_conv.inner = (void*)(e & (~1));
9893         e_conv.is_owned = (e & 1) || (e == 0);
9894         e_conv = DecodeError_clone(&e_conv);
9895         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9896         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
9897         return (uint64_t)ret_conv;
9898 }
9899
9900 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
9901         if ((_res & 1) != 0) return;
9902         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
9903         FREE((void*)_res);
9904         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
9905 }
9906
9907 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
9908         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
9909         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
9910         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
9911         return (uint64_t)ret_conv;
9912 }
9913
9914 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
9915         LDKRevokeAndACK o_conv;
9916         o_conv.inner = (void*)(o & (~1));
9917         o_conv.is_owned = (o & 1) || (o == 0);
9918         o_conv = RevokeAndACK_clone(&o_conv);
9919         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9920         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
9921         return (uint64_t)ret_conv;
9922 }
9923
9924 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
9925         LDKDecodeError e_conv;
9926         e_conv.inner = (void*)(e & (~1));
9927         e_conv.is_owned = (e & 1) || (e == 0);
9928         e_conv = DecodeError_clone(&e_conv);
9929         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9930         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
9931         return (uint64_t)ret_conv;
9932 }
9933
9934 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
9935         if ((_res & 1) != 0) return;
9936         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
9937         FREE((void*)_res);
9938         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
9939 }
9940
9941 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
9942         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
9943         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
9944         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
9945         return (uint64_t)ret_conv;
9946 }
9947
9948 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
9949         LDKShutdown o_conv;
9950         o_conv.inner = (void*)(o & (~1));
9951         o_conv.is_owned = (o & 1) || (o == 0);
9952         o_conv = Shutdown_clone(&o_conv);
9953         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9954         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
9955         return (uint64_t)ret_conv;
9956 }
9957
9958 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
9959         LDKDecodeError e_conv;
9960         e_conv.inner = (void*)(e & (~1));
9961         e_conv.is_owned = (e & 1) || (e == 0);
9962         e_conv = DecodeError_clone(&e_conv);
9963         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9964         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
9965         return (uint64_t)ret_conv;
9966 }
9967
9968 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
9969         if ((_res & 1) != 0) return;
9970         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
9971         FREE((void*)_res);
9972         CResult_ShutdownDecodeErrorZ_free(_res_conv);
9973 }
9974
9975 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
9976         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
9977         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
9978         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
9979         return (uint64_t)ret_conv;
9980 }
9981
9982 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
9983         LDKUpdateFailHTLC o_conv;
9984         o_conv.inner = (void*)(o & (~1));
9985         o_conv.is_owned = (o & 1) || (o == 0);
9986         o_conv = UpdateFailHTLC_clone(&o_conv);
9987         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9988         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
9989         return (uint64_t)ret_conv;
9990 }
9991
9992 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
9993         LDKDecodeError e_conv;
9994         e_conv.inner = (void*)(e & (~1));
9995         e_conv.is_owned = (e & 1) || (e == 0);
9996         e_conv = DecodeError_clone(&e_conv);
9997         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
9998         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
9999         return (uint64_t)ret_conv;
10000 }
10001
10002 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
10003         if ((_res & 1) != 0) return;
10004         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10005         FREE((void*)_res);
10006         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
10007 }
10008
10009 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
10010         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
10011         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
10012         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
10013         return (uint64_t)ret_conv;
10014 }
10015
10016 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
10017         LDKUpdateFailMalformedHTLC o_conv;
10018         o_conv.inner = (void*)(o & (~1));
10019         o_conv.is_owned = (o & 1) || (o == 0);
10020         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
10021         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10022         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
10023         return (uint64_t)ret_conv;
10024 }
10025
10026 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
10027         LDKDecodeError e_conv;
10028         e_conv.inner = (void*)(e & (~1));
10029         e_conv.is_owned = (e & 1) || (e == 0);
10030         e_conv = DecodeError_clone(&e_conv);
10031         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10032         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
10033         return (uint64_t)ret_conv;
10034 }
10035
10036 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
10037         if ((_res & 1) != 0) return;
10038         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10039         FREE((void*)_res);
10040         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
10041 }
10042
10043 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
10044         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
10045         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
10046         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
10047         return (uint64_t)ret_conv;
10048 }
10049
10050 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
10051         LDKUpdateFee o_conv;
10052         o_conv.inner = (void*)(o & (~1));
10053         o_conv.is_owned = (o & 1) || (o == 0);
10054         o_conv = UpdateFee_clone(&o_conv);
10055         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10056         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
10057         return (uint64_t)ret_conv;
10058 }
10059
10060 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
10061         LDKDecodeError e_conv;
10062         e_conv.inner = (void*)(e & (~1));
10063         e_conv.is_owned = (e & 1) || (e == 0);
10064         e_conv = DecodeError_clone(&e_conv);
10065         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10066         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
10067         return (uint64_t)ret_conv;
10068 }
10069
10070 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
10071         if ((_res & 1) != 0) return;
10072         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10073         FREE((void*)_res);
10074         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
10075 }
10076
10077 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
10078         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
10079         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
10080         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
10081         return (uint64_t)ret_conv;
10082 }
10083
10084 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
10085         LDKUpdateFulfillHTLC o_conv;
10086         o_conv.inner = (void*)(o & (~1));
10087         o_conv.is_owned = (o & 1) || (o == 0);
10088         o_conv = UpdateFulfillHTLC_clone(&o_conv);
10089         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10090         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
10095         LDKDecodeError e_conv;
10096         e_conv.inner = (void*)(e & (~1));
10097         e_conv.is_owned = (e & 1) || (e == 0);
10098         e_conv = DecodeError_clone(&e_conv);
10099         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10100         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
10101         return (uint64_t)ret_conv;
10102 }
10103
10104 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
10105         if ((_res & 1) != 0) return;
10106         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10107         FREE((void*)_res);
10108         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
10109 }
10110
10111 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
10112         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
10113         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
10114         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
10115         return (uint64_t)ret_conv;
10116 }
10117
10118 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
10119         LDKUpdateAddHTLC o_conv;
10120         o_conv.inner = (void*)(o & (~1));
10121         o_conv.is_owned = (o & 1) || (o == 0);
10122         o_conv = UpdateAddHTLC_clone(&o_conv);
10123         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10124         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
10125         return (uint64_t)ret_conv;
10126 }
10127
10128 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
10129         LDKDecodeError e_conv;
10130         e_conv.inner = (void*)(e & (~1));
10131         e_conv.is_owned = (e & 1) || (e == 0);
10132         e_conv = DecodeError_clone(&e_conv);
10133         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10134         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
10135         return (uint64_t)ret_conv;
10136 }
10137
10138 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
10139         if ((_res & 1) != 0) return;
10140         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
10141         FREE((void*)_res);
10142         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
10143 }
10144
10145 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
10146         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
10147         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
10148         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
10149         return (uint64_t)ret_conv;
10150 }
10151
10152 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
10153         LDKPing o_conv;
10154         o_conv.inner = (void*)(o & (~1));
10155         o_conv.is_owned = (o & 1) || (o == 0);
10156         o_conv = Ping_clone(&o_conv);
10157         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10158         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
10159         return (uint64_t)ret_conv;
10160 }
10161
10162 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
10163         LDKDecodeError e_conv;
10164         e_conv.inner = (void*)(e & (~1));
10165         e_conv.is_owned = (e & 1) || (e == 0);
10166         e_conv = DecodeError_clone(&e_conv);
10167         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10168         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
10169         return (uint64_t)ret_conv;
10170 }
10171
10172 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
10173         if ((_res & 1) != 0) return;
10174         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
10175         FREE((void*)_res);
10176         CResult_PingDecodeErrorZ_free(_res_conv);
10177 }
10178
10179 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
10180         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
10181         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
10182         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
10183         return (uint64_t)ret_conv;
10184 }
10185
10186 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
10187         LDKPong o_conv;
10188         o_conv.inner = (void*)(o & (~1));
10189         o_conv.is_owned = (o & 1) || (o == 0);
10190         o_conv = Pong_clone(&o_conv);
10191         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10192         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
10193         return (uint64_t)ret_conv;
10194 }
10195
10196 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
10197         LDKDecodeError e_conv;
10198         e_conv.inner = (void*)(e & (~1));
10199         e_conv.is_owned = (e & 1) || (e == 0);
10200         e_conv = DecodeError_clone(&e_conv);
10201         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10202         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
10203         return (uint64_t)ret_conv;
10204 }
10205
10206 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
10207         if ((_res & 1) != 0) return;
10208         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
10209         FREE((void*)_res);
10210         CResult_PongDecodeErrorZ_free(_res_conv);
10211 }
10212
10213 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
10214         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
10215         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
10216         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
10217         return (uint64_t)ret_conv;
10218 }
10219
10220 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10221         LDKUnsignedChannelAnnouncement o_conv;
10222         o_conv.inner = (void*)(o & (~1));
10223         o_conv.is_owned = (o & 1) || (o == 0);
10224         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
10225         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10226         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
10227         return (uint64_t)ret_conv;
10228 }
10229
10230 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10231         LDKDecodeError e_conv;
10232         e_conv.inner = (void*)(e & (~1));
10233         e_conv.is_owned = (e & 1) || (e == 0);
10234         e_conv = DecodeError_clone(&e_conv);
10235         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10236         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
10237         return (uint64_t)ret_conv;
10238 }
10239
10240 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10241         if ((_res & 1) != 0) return;
10242         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10243         FREE((void*)_res);
10244         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
10245 }
10246
10247 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10248         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10249         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
10250         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10251         return (uint64_t)ret_conv;
10252 }
10253
10254 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
10255         LDKChannelAnnouncement o_conv;
10256         o_conv.inner = (void*)(o & (~1));
10257         o_conv.is_owned = (o & 1) || (o == 0);
10258         o_conv = ChannelAnnouncement_clone(&o_conv);
10259         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10260         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
10261         return (uint64_t)ret_conv;
10262 }
10263
10264 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
10265         LDKDecodeError e_conv;
10266         e_conv.inner = (void*)(e & (~1));
10267         e_conv.is_owned = (e & 1) || (e == 0);
10268         e_conv = DecodeError_clone(&e_conv);
10269         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10270         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
10271         return (uint64_t)ret_conv;
10272 }
10273
10274 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
10275         if ((_res & 1) != 0) return;
10276         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10277         FREE((void*)_res);
10278         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
10279 }
10280
10281 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10282         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
10283         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
10284         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
10285         return (uint64_t)ret_conv;
10286 }
10287
10288 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10289         LDKUnsignedChannelUpdate o_conv;
10290         o_conv.inner = (void*)(o & (~1));
10291         o_conv.is_owned = (o & 1) || (o == 0);
10292         o_conv = UnsignedChannelUpdate_clone(&o_conv);
10293         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10294         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
10295         return (uint64_t)ret_conv;
10296 }
10297
10298 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
10299         LDKDecodeError e_conv;
10300         e_conv.inner = (void*)(e & (~1));
10301         e_conv.is_owned = (e & 1) || (e == 0);
10302         e_conv = DecodeError_clone(&e_conv);
10303         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10304         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
10305         return (uint64_t)ret_conv;
10306 }
10307
10308 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10309         if ((_res & 1) != 0) return;
10310         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10311         FREE((void*)_res);
10312         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
10313 }
10314
10315 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10316         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
10317         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
10318         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
10319         return (uint64_t)ret_conv;
10320 }
10321
10322 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
10323         LDKChannelUpdate o_conv;
10324         o_conv.inner = (void*)(o & (~1));
10325         o_conv.is_owned = (o & 1) || (o == 0);
10326         o_conv = ChannelUpdate_clone(&o_conv);
10327         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10328         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
10329         return (uint64_t)ret_conv;
10330 }
10331
10332 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
10333         LDKDecodeError e_conv;
10334         e_conv.inner = (void*)(e & (~1));
10335         e_conv.is_owned = (e & 1) || (e == 0);
10336         e_conv = DecodeError_clone(&e_conv);
10337         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10338         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
10339         return (uint64_t)ret_conv;
10340 }
10341
10342 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
10343         if ((_res & 1) != 0) return;
10344         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10345         FREE((void*)_res);
10346         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
10347 }
10348
10349 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
10350         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
10351         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
10352         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
10353         return (uint64_t)ret_conv;
10354 }
10355
10356 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
10357         LDKErrorMessage o_conv;
10358         o_conv.inner = (void*)(o & (~1));
10359         o_conv.is_owned = (o & 1) || (o == 0);
10360         o_conv = ErrorMessage_clone(&o_conv);
10361         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10362         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
10363         return (uint64_t)ret_conv;
10364 }
10365
10366 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
10367         LDKDecodeError e_conv;
10368         e_conv.inner = (void*)(e & (~1));
10369         e_conv.is_owned = (e & 1) || (e == 0);
10370         e_conv = DecodeError_clone(&e_conv);
10371         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10372         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
10373         return (uint64_t)ret_conv;
10374 }
10375
10376 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
10377         if ((_res & 1) != 0) return;
10378         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
10379         FREE((void*)_res);
10380         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
10381 }
10382
10383 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
10384         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
10385         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
10386         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
10387         return (uint64_t)ret_conv;
10388 }
10389
10390 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10391         LDKUnsignedNodeAnnouncement o_conv;
10392         o_conv.inner = (void*)(o & (~1));
10393         o_conv.is_owned = (o & 1) || (o == 0);
10394         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
10395         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10396         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
10397         return (uint64_t)ret_conv;
10398 }
10399
10400 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10401         LDKDecodeError e_conv;
10402         e_conv.inner = (void*)(e & (~1));
10403         e_conv.is_owned = (e & 1) || (e == 0);
10404         e_conv = DecodeError_clone(&e_conv);
10405         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10406         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
10407         return (uint64_t)ret_conv;
10408 }
10409
10410 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10411         if ((_res & 1) != 0) return;
10412         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10413         FREE((void*)_res);
10414         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
10415 }
10416
10417 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
10419         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
10420         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
10421         return (uint64_t)ret_conv;
10422 }
10423
10424 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
10425         LDKNodeAnnouncement o_conv;
10426         o_conv.inner = (void*)(o & (~1));
10427         o_conv.is_owned = (o & 1) || (o == 0);
10428         o_conv = NodeAnnouncement_clone(&o_conv);
10429         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10430         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
10431         return (uint64_t)ret_conv;
10432 }
10433
10434 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
10435         LDKDecodeError e_conv;
10436         e_conv.inner = (void*)(e & (~1));
10437         e_conv.is_owned = (e & 1) || (e == 0);
10438         e_conv = DecodeError_clone(&e_conv);
10439         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10440         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
10441         return (uint64_t)ret_conv;
10442 }
10443
10444 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
10445         if ((_res & 1) != 0) return;
10446         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
10447         FREE((void*)_res);
10448         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
10449 }
10450
10451 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
10452         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
10453         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
10454         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
10455         return (uint64_t)ret_conv;
10456 }
10457
10458 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
10459         LDKQueryShortChannelIds o_conv;
10460         o_conv.inner = (void*)(o & (~1));
10461         o_conv.is_owned = (o & 1) || (o == 0);
10462         o_conv = QueryShortChannelIds_clone(&o_conv);
10463         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10464         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
10465         return (uint64_t)ret_conv;
10466 }
10467
10468 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
10469         LDKDecodeError e_conv;
10470         e_conv.inner = (void*)(e & (~1));
10471         e_conv.is_owned = (e & 1) || (e == 0);
10472         e_conv = DecodeError_clone(&e_conv);
10473         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10474         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
10475         return (uint64_t)ret_conv;
10476 }
10477
10478 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
10479         if ((_res & 1) != 0) return;
10480         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
10481         FREE((void*)_res);
10482         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
10483 }
10484
10485 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
10486         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
10487         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
10488         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
10489         return (uint64_t)ret_conv;
10490 }
10491
10492 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
10493         LDKReplyShortChannelIdsEnd o_conv;
10494         o_conv.inner = (void*)(o & (~1));
10495         o_conv.is_owned = (o & 1) || (o == 0);
10496         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
10497         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10498         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
10499         return (uint64_t)ret_conv;
10500 }
10501
10502 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
10503         LDKDecodeError e_conv;
10504         e_conv.inner = (void*)(e & (~1));
10505         e_conv.is_owned = (e & 1) || (e == 0);
10506         e_conv = DecodeError_clone(&e_conv);
10507         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10508         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
10509         return (uint64_t)ret_conv;
10510 }
10511
10512 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
10513         if ((_res & 1) != 0) return;
10514         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
10515         FREE((void*)_res);
10516         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
10517 }
10518
10519 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
10520         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
10521         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
10522         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
10523         return (uint64_t)ret_conv;
10524 }
10525
10526 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
10527         LDKQueryChannelRange o_conv;
10528         o_conv.inner = (void*)(o & (~1));
10529         o_conv.is_owned = (o & 1) || (o == 0);
10530         o_conv = QueryChannelRange_clone(&o_conv);
10531         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10532         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
10533         return (uint64_t)ret_conv;
10534 }
10535
10536 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
10537         LDKDecodeError e_conv;
10538         e_conv.inner = (void*)(e & (~1));
10539         e_conv.is_owned = (e & 1) || (e == 0);
10540         e_conv = DecodeError_clone(&e_conv);
10541         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10542         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
10543         return (uint64_t)ret_conv;
10544 }
10545
10546 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
10547         if ((_res & 1) != 0) return;
10548         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10549         FREE((void*)_res);
10550         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
10551 }
10552
10553 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10554         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
10555         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
10556         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
10557         return (uint64_t)ret_conv;
10558 }
10559
10560 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
10561         LDKReplyChannelRange o_conv;
10562         o_conv.inner = (void*)(o & (~1));
10563         o_conv.is_owned = (o & 1) || (o == 0);
10564         o_conv = ReplyChannelRange_clone(&o_conv);
10565         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10566         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
10567         return (uint64_t)ret_conv;
10568 }
10569
10570 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
10571         LDKDecodeError e_conv;
10572         e_conv.inner = (void*)(e & (~1));
10573         e_conv.is_owned = (e & 1) || (e == 0);
10574         e_conv = DecodeError_clone(&e_conv);
10575         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10576         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
10577         return (uint64_t)ret_conv;
10578 }
10579
10580 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
10581         if ((_res & 1) != 0) return;
10582         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10583         FREE((void*)_res);
10584         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
10585 }
10586
10587 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
10588         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
10589         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
10590         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
10591         return (uint64_t)ret_conv;
10592 }
10593
10594 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
10595         LDKGossipTimestampFilter o_conv;
10596         o_conv.inner = (void*)(o & (~1));
10597         o_conv.is_owned = (o & 1) || (o == 0);
10598         o_conv = GossipTimestampFilter_clone(&o_conv);
10599         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10600         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
10601         return (uint64_t)ret_conv;
10602 }
10603
10604 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
10605         LDKDecodeError e_conv;
10606         e_conv.inner = (void*)(e & (~1));
10607         e_conv.is_owned = (e & 1) || (e == 0);
10608         e_conv = DecodeError_clone(&e_conv);
10609         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10610         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
10611         return (uint64_t)ret_conv;
10612 }
10613
10614 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
10615         if ((_res & 1) != 0) return;
10616         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
10617         FREE((void*)_res);
10618         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
10619 }
10620
10621 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
10622         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
10623         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
10624         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
10625         return (uint64_t)ret_conv;
10626 }
10627
10628 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
10629         LDKInvoice o_conv;
10630         o_conv.inner = (void*)(o & (~1));
10631         o_conv.is_owned = (o & 1) || (o == 0);
10632         o_conv = Invoice_clone(&o_conv);
10633         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10634         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
10635         return (uint64_t)ret_conv;
10636 }
10637
10638 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
10639         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
10640         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10641         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
10642         return (uint64_t)ret_conv;
10643 }
10644
10645 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
10646         if ((_res & 1) != 0) return;
10647         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
10648         FREE((void*)_res);
10649         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
10650 }
10651
10652 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
10653         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
10654         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
10655         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
10656         return (uint64_t)ret_conv;
10657 }
10658
10659 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
10660         if ((this_ptr & 1) != 0) return;
10661         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
10662         FREE((void*)this_ptr);
10663         Event_free(this_ptr_conv);
10664 }
10665
10666 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
10667         LDKEvent* orig_conv = (LDKEvent*)orig;
10668         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
10669         *ret_copy = Event_clone(orig_conv);
10670         uint64_t ret_ref = (uint64_t)ret_copy;
10671         return ret_ref;
10672 }
10673
10674 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
10675         LDKEvent* obj_conv = (LDKEvent*)obj;
10676         LDKCVec_u8Z ret_var = Event_write(obj_conv);
10677         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10678         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10679         CVec_u8Z_free(ret_var);
10680         return ret_arr;
10681 }
10682
10683 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
10684         if ((this_ptr & 1) != 0) return;
10685         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
10686         FREE((void*)this_ptr);
10687         MessageSendEvent_free(this_ptr_conv);
10688 }
10689
10690 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
10691         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
10692         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10693         *ret_copy = MessageSendEvent_clone(orig_conv);
10694         uint64_t ret_ref = (uint64_t)ret_copy;
10695         return ret_ref;
10696 }
10697
10698 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
10699         if ((this_ptr & 1) != 0) return;
10700         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
10701         FREE((void*)this_ptr);
10702         MessageSendEventsProvider_free(this_ptr_conv);
10703 }
10704
10705 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
10706         if ((this_ptr & 1) != 0) return;
10707         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
10708         FREE((void*)this_ptr);
10709         EventsProvider_free(this_ptr_conv);
10710 }
10711
10712 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
10713         if ((this_ptr & 1) != 0) return;
10714         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
10715         FREE((void*)this_ptr);
10716         EventHandler_free(this_ptr_conv);
10717 }
10718
10719 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
10720         if ((this_ptr & 1) != 0) return;
10721         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
10722         FREE((void*)this_ptr);
10723         APIError_free(this_ptr_conv);
10724 }
10725
10726 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
10727         LDKAPIError* orig_conv = (LDKAPIError*)orig;
10728         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
10729         *ret_copy = APIError_clone(orig_conv);
10730         uint64_t ret_ref = (uint64_t)ret_copy;
10731         return ret_ref;
10732 }
10733
10734 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
10735         LDKu8slice msg_ref;
10736         msg_ref.datalen = *((uint32_t*)msg);
10737         msg_ref.data = (int8_t*)(msg + 4);
10738         LDKSecretKey sk_ref;
10739         CHECK(*((uint32_t*)sk) == 32);
10740         memcpy(sk_ref.bytes, (uint8_t*)(sk + 4), 32);
10741         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10742         *ret_conv = sign(msg_ref, sk_ref);
10743         return (uint64_t)ret_conv;
10744 }
10745
10746 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
10747         LDKu8slice msg_ref;
10748         msg_ref.datalen = *((uint32_t*)msg);
10749         msg_ref.data = (int8_t*)(msg + 4);
10750         LDKStr sig_conv = str_ref_to_owned_c(sig);
10751         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10752         *ret_conv = recover_pk(msg_ref, sig_conv);
10753         return (uint64_t)ret_conv;
10754 }
10755
10756 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
10757         LDKu8slice msg_ref;
10758         msg_ref.datalen = *((uint32_t*)msg);
10759         msg_ref.data = (int8_t*)(msg + 4);
10760         LDKStr sig_conv = str_ref_to_owned_c(sig);
10761         LDKPublicKey pk_ref;
10762         CHECK(*((uint32_t*)pk) == 33);
10763         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
10764         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
10765         return ret_val;
10766 }
10767
10768 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
10769         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
10770         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
10771         return ret_conv;
10772 }
10773
10774 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
10775         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
10776         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
10777         jboolean ret_val = Level_eq(a_conv, b_conv);
10778         return ret_val;
10779 }
10780
10781 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
10782         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
10783         int64_t ret_val = Level_hash(o_conv);
10784         return ret_val;
10785 }
10786
10787 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
10788         uint32_t ret_conv = LDKLevel_to_js(Level_max());
10789         return ret_conv;
10790 }
10791
10792 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
10793         if ((this_ptr & 1) != 0) return;
10794         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
10795         FREE((void*)this_ptr);
10796         Logger_free(this_ptr_conv);
10797 }
10798
10799 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
10800         LDKChannelHandshakeConfig this_obj_conv;
10801         this_obj_conv.inner = (void*)(this_obj & (~1));
10802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10803         ChannelHandshakeConfig_free(this_obj_conv);
10804 }
10805
10806 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
10807         LDKChannelHandshakeConfig this_ptr_conv;
10808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10809         this_ptr_conv.is_owned = false;
10810         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
10811         return ret_val;
10812 }
10813
10814 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
10815         LDKChannelHandshakeConfig this_ptr_conv;
10816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10817         this_ptr_conv.is_owned = false;
10818         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
10819 }
10820
10821 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
10822         LDKChannelHandshakeConfig this_ptr_conv;
10823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10824         this_ptr_conv.is_owned = false;
10825         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
10826         return ret_val;
10827 }
10828
10829 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
10830         LDKChannelHandshakeConfig this_ptr_conv;
10831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10832         this_ptr_conv.is_owned = false;
10833         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
10834 }
10835
10836 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
10837         LDKChannelHandshakeConfig this_ptr_conv;
10838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10839         this_ptr_conv.is_owned = false;
10840         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
10841         return ret_val;
10842 }
10843
10844 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10845         LDKChannelHandshakeConfig this_ptr_conv;
10846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10847         this_ptr_conv.is_owned = false;
10848         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
10849 }
10850
10851 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) {
10852         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
10853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10855         uint64_t ret_ref = (uint64_t)ret_var.inner;
10856         if (ret_var.is_owned) {
10857                 ret_ref |= 1;
10858         }
10859         return ret_ref;
10860 }
10861
10862 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
10863         LDKChannelHandshakeConfig orig_conv;
10864         orig_conv.inner = (void*)(orig & (~1));
10865         orig_conv.is_owned = false;
10866         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
10867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10869         uint64_t ret_ref = (uint64_t)ret_var.inner;
10870         if (ret_var.is_owned) {
10871                 ret_ref |= 1;
10872         }
10873         return ret_ref;
10874 }
10875
10876 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
10877         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
10878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10880         uint64_t ret_ref = (uint64_t)ret_var.inner;
10881         if (ret_var.is_owned) {
10882                 ret_ref |= 1;
10883         }
10884         return ret_ref;
10885 }
10886
10887 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
10888         LDKChannelHandshakeLimits this_obj_conv;
10889         this_obj_conv.inner = (void*)(this_obj & (~1));
10890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10891         ChannelHandshakeLimits_free(this_obj_conv);
10892 }
10893
10894 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
10895         LDKChannelHandshakeLimits this_ptr_conv;
10896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10897         this_ptr_conv.is_owned = false;
10898         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
10899         return ret_val;
10900 }
10901
10902 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
10903         LDKChannelHandshakeLimits this_ptr_conv;
10904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10905         this_ptr_conv.is_owned = false;
10906         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
10907 }
10908
10909 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
10910         LDKChannelHandshakeLimits this_ptr_conv;
10911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10912         this_ptr_conv.is_owned = false;
10913         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
10914         return ret_val;
10915 }
10916
10917 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
10918         LDKChannelHandshakeLimits this_ptr_conv;
10919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10920         this_ptr_conv.is_owned = false;
10921         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
10922 }
10923
10924 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
10925         LDKChannelHandshakeLimits this_ptr_conv;
10926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10927         this_ptr_conv.is_owned = false;
10928         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
10929         return ret_val;
10930 }
10931
10932 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
10933         LDKChannelHandshakeLimits this_ptr_conv;
10934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10935         this_ptr_conv.is_owned = false;
10936         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
10937 }
10938
10939 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
10940         LDKChannelHandshakeLimits this_ptr_conv;
10941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10942         this_ptr_conv.is_owned = false;
10943         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
10944         return ret_val;
10945 }
10946
10947 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
10948         LDKChannelHandshakeLimits this_ptr_conv;
10949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10950         this_ptr_conv.is_owned = false;
10951         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
10952 }
10953
10954 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
10955         LDKChannelHandshakeLimits this_ptr_conv;
10956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10957         this_ptr_conv.is_owned = false;
10958         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
10959         return ret_val;
10960 }
10961
10962 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
10963         LDKChannelHandshakeLimits this_ptr_conv;
10964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10965         this_ptr_conv.is_owned = false;
10966         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
10967 }
10968
10969 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
10970         LDKChannelHandshakeLimits this_ptr_conv;
10971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10972         this_ptr_conv.is_owned = false;
10973         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
10974         return ret_val;
10975 }
10976
10977 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
10978         LDKChannelHandshakeLimits this_ptr_conv;
10979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10980         this_ptr_conv.is_owned = false;
10981         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
10982 }
10983
10984 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
10985         LDKChannelHandshakeLimits this_ptr_conv;
10986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10987         this_ptr_conv.is_owned = false;
10988         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
10989         return ret_val;
10990 }
10991
10992 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
10993         LDKChannelHandshakeLimits this_ptr_conv;
10994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10995         this_ptr_conv.is_owned = false;
10996         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
10997 }
10998
10999 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
11000         LDKChannelHandshakeLimits this_ptr_conv;
11001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11002         this_ptr_conv.is_owned = false;
11003         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
11004         return ret_val;
11005 }
11006
11007 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
11008         LDKChannelHandshakeLimits this_ptr_conv;
11009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11010         this_ptr_conv.is_owned = false;
11011         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
11012 }
11013
11014 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) {
11015         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);
11016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11018         uint64_t ret_ref = (uint64_t)ret_var.inner;
11019         if (ret_var.is_owned) {
11020                 ret_ref |= 1;
11021         }
11022         return ret_ref;
11023 }
11024
11025 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
11026         LDKChannelHandshakeLimits orig_conv;
11027         orig_conv.inner = (void*)(orig & (~1));
11028         orig_conv.is_owned = false;
11029         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
11030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11032         uint64_t ret_ref = (uint64_t)ret_var.inner;
11033         if (ret_var.is_owned) {
11034                 ret_ref |= 1;
11035         }
11036         return ret_ref;
11037 }
11038
11039 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
11040         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
11041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11043         uint64_t ret_ref = (uint64_t)ret_var.inner;
11044         if (ret_var.is_owned) {
11045                 ret_ref |= 1;
11046         }
11047         return ret_ref;
11048 }
11049
11050 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
11051         LDKChannelConfig this_obj_conv;
11052         this_obj_conv.inner = (void*)(this_obj & (~1));
11053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11054         ChannelConfig_free(this_obj_conv);
11055 }
11056
11057 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
11058         LDKChannelConfig this_ptr_conv;
11059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11060         this_ptr_conv.is_owned = false;
11061         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
11062         return ret_val;
11063 }
11064
11065 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11066         LDKChannelConfig this_ptr_conv;
11067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11068         this_ptr_conv.is_owned = false;
11069         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
11070 }
11071
11072 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
11073         LDKChannelConfig this_ptr_conv;
11074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11075         this_ptr_conv.is_owned = false;
11076         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
11077         return ret_val;
11078 }
11079
11080 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11081         LDKChannelConfig this_ptr_conv;
11082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11083         this_ptr_conv.is_owned = false;
11084         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
11085 }
11086
11087 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
11088         LDKChannelConfig this_ptr_conv;
11089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11090         this_ptr_conv.is_owned = false;
11091         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
11092         return ret_val;
11093 }
11094
11095 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
11096         LDKChannelConfig this_ptr_conv;
11097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11098         this_ptr_conv.is_owned = false;
11099         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
11100 }
11101
11102 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
11103         LDKChannelConfig this_ptr_conv;
11104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11105         this_ptr_conv.is_owned = false;
11106         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
11107         return ret_val;
11108 }
11109
11110 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
11111         LDKChannelConfig this_ptr_conv;
11112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11113         this_ptr_conv.is_owned = false;
11114         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
11115 }
11116
11117 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
11118         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
11119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11121         uint64_t ret_ref = (uint64_t)ret_var.inner;
11122         if (ret_var.is_owned) {
11123                 ret_ref |= 1;
11124         }
11125         return ret_ref;
11126 }
11127
11128 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
11129         LDKChannelConfig orig_conv;
11130         orig_conv.inner = (void*)(orig & (~1));
11131         orig_conv.is_owned = false;
11132         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
11133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11135         uint64_t ret_ref = (uint64_t)ret_var.inner;
11136         if (ret_var.is_owned) {
11137                 ret_ref |= 1;
11138         }
11139         return ret_ref;
11140 }
11141
11142 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
11143         LDKChannelConfig ret_var = ChannelConfig_default();
11144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11146         uint64_t ret_ref = (uint64_t)ret_var.inner;
11147         if (ret_var.is_owned) {
11148                 ret_ref |= 1;
11149         }
11150         return ret_ref;
11151 }
11152
11153 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
11154         LDKChannelConfig obj_conv;
11155         obj_conv.inner = (void*)(obj & (~1));
11156         obj_conv.is_owned = false;
11157         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
11158         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11159         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11160         CVec_u8Z_free(ret_var);
11161         return ret_arr;
11162 }
11163
11164 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
11165         LDKu8slice ser_ref;
11166         ser_ref.datalen = *((uint32_t*)ser);
11167         ser_ref.data = (int8_t*)(ser + 4);
11168         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11169         *ret_conv = ChannelConfig_read(ser_ref);
11170         return (uint64_t)ret_conv;
11171 }
11172
11173 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
11174         LDKUserConfig this_obj_conv;
11175         this_obj_conv.inner = (void*)(this_obj & (~1));
11176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11177         UserConfig_free(this_obj_conv);
11178 }
11179
11180 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
11181         LDKUserConfig this_ptr_conv;
11182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11183         this_ptr_conv.is_owned = false;
11184         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
11185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11187         uint64_t ret_ref = (uint64_t)ret_var.inner;
11188         if (ret_var.is_owned) {
11189                 ret_ref |= 1;
11190         }
11191         return ret_ref;
11192 }
11193
11194 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
11195         LDKUserConfig this_ptr_conv;
11196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11197         this_ptr_conv.is_owned = false;
11198         LDKChannelHandshakeConfig val_conv;
11199         val_conv.inner = (void*)(val & (~1));
11200         val_conv.is_owned = (val & 1) || (val == 0);
11201         val_conv = ChannelHandshakeConfig_clone(&val_conv);
11202         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
11203 }
11204
11205 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
11206         LDKUserConfig this_ptr_conv;
11207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11208         this_ptr_conv.is_owned = false;
11209         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
11210         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11211         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11212         uint64_t ret_ref = (uint64_t)ret_var.inner;
11213         if (ret_var.is_owned) {
11214                 ret_ref |= 1;
11215         }
11216         return ret_ref;
11217 }
11218
11219 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
11220         LDKUserConfig this_ptr_conv;
11221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11222         this_ptr_conv.is_owned = false;
11223         LDKChannelHandshakeLimits val_conv;
11224         val_conv.inner = (void*)(val & (~1));
11225         val_conv.is_owned = (val & 1) || (val == 0);
11226         val_conv = ChannelHandshakeLimits_clone(&val_conv);
11227         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
11228 }
11229
11230 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
11231         LDKUserConfig this_ptr_conv;
11232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11233         this_ptr_conv.is_owned = false;
11234         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
11235         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11236         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11237         uint64_t ret_ref = (uint64_t)ret_var.inner;
11238         if (ret_var.is_owned) {
11239                 ret_ref |= 1;
11240         }
11241         return ret_ref;
11242 }
11243
11244 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
11245         LDKUserConfig this_ptr_conv;
11246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11247         this_ptr_conv.is_owned = false;
11248         LDKChannelConfig val_conv;
11249         val_conv.inner = (void*)(val & (~1));
11250         val_conv.is_owned = (val & 1) || (val == 0);
11251         val_conv = ChannelConfig_clone(&val_conv);
11252         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
11253 }
11254
11255 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) {
11256         LDKChannelHandshakeConfig own_channel_config_arg_conv;
11257         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
11258         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
11259         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
11260         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
11261         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
11262         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
11263         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
11264         LDKChannelConfig channel_options_arg_conv;
11265         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
11266         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
11267         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
11268         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
11269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11271         uint64_t ret_ref = (uint64_t)ret_var.inner;
11272         if (ret_var.is_owned) {
11273                 ret_ref |= 1;
11274         }
11275         return ret_ref;
11276 }
11277
11278 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
11279         LDKUserConfig orig_conv;
11280         orig_conv.inner = (void*)(orig & (~1));
11281         orig_conv.is_owned = false;
11282         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
11283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11285         uint64_t ret_ref = (uint64_t)ret_var.inner;
11286         if (ret_var.is_owned) {
11287                 ret_ref |= 1;
11288         }
11289         return ret_ref;
11290 }
11291
11292 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
11293         LDKUserConfig ret_var = UserConfig_default();
11294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11296         uint64_t ret_ref = (uint64_t)ret_var.inner;
11297         if (ret_var.is_owned) {
11298                 ret_ref |= 1;
11299         }
11300         return ret_ref;
11301 }
11302
11303 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
11304         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
11305         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
11306         return ret_conv;
11307 }
11308
11309 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
11310         if ((this_ptr & 1) != 0) return;
11311         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
11312         FREE((void*)this_ptr);
11313         Access_free(this_ptr_conv);
11314 }
11315
11316 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
11317         if ((this_ptr & 1) != 0) return;
11318         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
11319         FREE((void*)this_ptr);
11320         Listen_free(this_ptr_conv);
11321 }
11322
11323 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
11324         if ((this_ptr & 1) != 0) return;
11325         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
11326         FREE((void*)this_ptr);
11327         Confirm_free(this_ptr_conv);
11328 }
11329
11330 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
11331         if ((this_ptr & 1) != 0) return;
11332         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
11333         FREE((void*)this_ptr);
11334         Watch_free(this_ptr_conv);
11335 }
11336
11337 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
11338         if ((this_ptr & 1) != 0) return;
11339         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
11340         FREE((void*)this_ptr);
11341         Filter_free(this_ptr_conv);
11342 }
11343
11344 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
11345         LDKWatchedOutput this_obj_conv;
11346         this_obj_conv.inner = (void*)(this_obj & (~1));
11347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11348         WatchedOutput_free(this_obj_conv);
11349 }
11350
11351 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
11352         LDKWatchedOutput this_ptr_conv;
11353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11354         this_ptr_conv.is_owned = false;
11355         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11356         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
11357         return ret_arr;
11358 }
11359
11360 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
11361         LDKWatchedOutput this_ptr_conv;
11362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11363         this_ptr_conv.is_owned = false;
11364         LDKThirtyTwoBytes val_ref;
11365         CHECK(*((uint32_t*)val) == 32);
11366         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11367         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
11368 }
11369
11370 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
11371         LDKWatchedOutput this_ptr_conv;
11372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11373         this_ptr_conv.is_owned = false;
11374         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
11375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11377         uint64_t ret_ref = (uint64_t)ret_var.inner;
11378         if (ret_var.is_owned) {
11379                 ret_ref |= 1;
11380         }
11381         return ret_ref;
11382 }
11383
11384 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
11385         LDKWatchedOutput this_ptr_conv;
11386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11387         this_ptr_conv.is_owned = false;
11388         LDKOutPoint val_conv;
11389         val_conv.inner = (void*)(val & (~1));
11390         val_conv.is_owned = (val & 1) || (val == 0);
11391         val_conv = OutPoint_clone(&val_conv);
11392         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
11393 }
11394
11395 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
11396         LDKWatchedOutput this_ptr_conv;
11397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11398         this_ptr_conv.is_owned = false;
11399         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
11400         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11401         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11402         return ret_arr;
11403 }
11404
11405 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
11406         LDKWatchedOutput this_ptr_conv;
11407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11408         this_ptr_conv.is_owned = false;
11409         LDKCVec_u8Z val_ref;
11410         val_ref.datalen = *((uint32_t*)val);
11411         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11412         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11413         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
11414 }
11415
11416 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
11417         LDKThirtyTwoBytes block_hash_arg_ref;
11418         CHECK(*((uint32_t*)block_hash_arg) == 32);
11419         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
11420         LDKOutPoint outpoint_arg_conv;
11421         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
11422         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
11423         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
11424         LDKCVec_u8Z script_pubkey_arg_ref;
11425         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
11426         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11427         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
11428         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
11429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11431         uint64_t ret_ref = (uint64_t)ret_var.inner;
11432         if (ret_var.is_owned) {
11433                 ret_ref |= 1;
11434         }
11435         return ret_ref;
11436 }
11437
11438 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
11439         LDKWatchedOutput orig_conv;
11440         orig_conv.inner = (void*)(orig & (~1));
11441         orig_conv.is_owned = false;
11442         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
11443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11445         uint64_t ret_ref = (uint64_t)ret_var.inner;
11446         if (ret_var.is_owned) {
11447                 ret_ref |= 1;
11448         }
11449         return ret_ref;
11450 }
11451
11452 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
11453         LDKWatchedOutput o_conv;
11454         o_conv.inner = (void*)(o & (~1));
11455         o_conv.is_owned = false;
11456         int64_t ret_val = WatchedOutput_hash(&o_conv);
11457         return ret_val;
11458 }
11459
11460 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
11461         if ((this_ptr & 1) != 0) return;
11462         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
11463         FREE((void*)this_ptr);
11464         BroadcasterInterface_free(this_ptr_conv);
11465 }
11466
11467 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
11468         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
11469         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
11470         return ret_conv;
11471 }
11472
11473 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
11474         if ((this_ptr & 1) != 0) return;
11475         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
11476         FREE((void*)this_ptr);
11477         FeeEstimator_free(this_ptr_conv);
11478 }
11479
11480 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
11481         LDKChainMonitor this_obj_conv;
11482         this_obj_conv.inner = (void*)(this_obj & (~1));
11483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11484         ChainMonitor_free(this_obj_conv);
11485 }
11486
11487 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
11488         LDKFilter *chain_source_conv_ptr = NULL;
11489         if (chain_source != 0) {
11490                 LDKFilter chain_source_conv;
11491                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
11492                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11493                 *chain_source_conv_ptr = chain_source_conv;
11494         }
11495         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11496         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11497         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
11498         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
11499         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
11500         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11501         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11502         uint64_t ret_ref = (uint64_t)ret_var.inner;
11503         if (ret_var.is_owned) {
11504                 ret_ref |= 1;
11505         }
11506         return ret_ref;
11507 }
11508
11509 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
11510         LDKChainMonitor this_arg_conv;
11511         this_arg_conv.inner = (void*)(this_arg & (~1));
11512         this_arg_conv.is_owned = false;
11513         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11514         *ret = ChainMonitor_as_Listen(&this_arg_conv);
11515         return (uint64_t)ret;
11516 }
11517
11518 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
11519         LDKChainMonitor this_arg_conv;
11520         this_arg_conv.inner = (void*)(this_arg & (~1));
11521         this_arg_conv.is_owned = false;
11522         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11523         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
11524         return (uint64_t)ret;
11525 }
11526
11527 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
11528         LDKChainMonitor this_arg_conv;
11529         this_arg_conv.inner = (void*)(this_arg & (~1));
11530         this_arg_conv.is_owned = false;
11531         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
11532         *ret = ChainMonitor_as_Watch(&this_arg_conv);
11533         return (uint64_t)ret;
11534 }
11535
11536 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
11537         LDKChainMonitor this_arg_conv;
11538         this_arg_conv.inner = (void*)(this_arg & (~1));
11539         this_arg_conv.is_owned = false;
11540         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11541         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
11542         return (uint64_t)ret;
11543 }
11544
11545 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
11546         LDKChannelMonitorUpdate this_obj_conv;
11547         this_obj_conv.inner = (void*)(this_obj & (~1));
11548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11549         ChannelMonitorUpdate_free(this_obj_conv);
11550 }
11551
11552 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
11553         LDKChannelMonitorUpdate this_ptr_conv;
11554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11555         this_ptr_conv.is_owned = false;
11556         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
11557         return ret_val;
11558 }
11559
11560 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
11561         LDKChannelMonitorUpdate this_ptr_conv;
11562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11563         this_ptr_conv.is_owned = false;
11564         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
11565 }
11566
11567 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
11568         LDKChannelMonitorUpdate orig_conv;
11569         orig_conv.inner = (void*)(orig & (~1));
11570         orig_conv.is_owned = false;
11571         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
11572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11574         uint64_t ret_ref = (uint64_t)ret_var.inner;
11575         if (ret_var.is_owned) {
11576                 ret_ref |= 1;
11577         }
11578         return ret_ref;
11579 }
11580
11581 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
11582         LDKChannelMonitorUpdate obj_conv;
11583         obj_conv.inner = (void*)(obj & (~1));
11584         obj_conv.is_owned = false;
11585         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
11586         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11587         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11588         CVec_u8Z_free(ret_var);
11589         return ret_arr;
11590 }
11591
11592 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
11593         LDKu8slice ser_ref;
11594         ser_ref.datalen = *((uint32_t*)ser);
11595         ser_ref.data = (int8_t*)(ser + 4);
11596         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11597         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
11598         return (uint64_t)ret_conv;
11599 }
11600
11601 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
11602         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
11603         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
11604         return ret_conv;
11605 }
11606
11607 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
11608         LDKMonitorUpdateError this_obj_conv;
11609         this_obj_conv.inner = (void*)(this_obj & (~1));
11610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11611         MonitorUpdateError_free(this_obj_conv);
11612 }
11613
11614 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
11615         LDKMonitorUpdateError orig_conv;
11616         orig_conv.inner = (void*)(orig & (~1));
11617         orig_conv.is_owned = false;
11618         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
11619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11621         uint64_t ret_ref = (uint64_t)ret_var.inner;
11622         if (ret_var.is_owned) {
11623                 ret_ref |= 1;
11624         }
11625         return ret_ref;
11626 }
11627
11628 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
11629         if ((this_ptr & 1) != 0) return;
11630         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
11631         FREE((void*)this_ptr);
11632         MonitorEvent_free(this_ptr_conv);
11633 }
11634
11635 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
11636         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
11637         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11638         *ret_copy = MonitorEvent_clone(orig_conv);
11639         uint64_t ret_ref = (uint64_t)ret_copy;
11640         return ret_ref;
11641 }
11642
11643 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
11644         LDKHTLCUpdate this_obj_conv;
11645         this_obj_conv.inner = (void*)(this_obj & (~1));
11646         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11647         HTLCUpdate_free(this_obj_conv);
11648 }
11649
11650 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
11651         LDKHTLCUpdate orig_conv;
11652         orig_conv.inner = (void*)(orig & (~1));
11653         orig_conv.is_owned = false;
11654         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
11655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11657         uint64_t ret_ref = (uint64_t)ret_var.inner;
11658         if (ret_var.is_owned) {
11659                 ret_ref |= 1;
11660         }
11661         return ret_ref;
11662 }
11663
11664 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
11665         LDKHTLCUpdate obj_conv;
11666         obj_conv.inner = (void*)(obj & (~1));
11667         obj_conv.is_owned = false;
11668         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
11669         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11670         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11671         CVec_u8Z_free(ret_var);
11672         return ret_arr;
11673 }
11674
11675 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
11676         LDKu8slice ser_ref;
11677         ser_ref.datalen = *((uint32_t*)ser);
11678         ser_ref.data = (int8_t*)(ser + 4);
11679         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11680         *ret_conv = HTLCUpdate_read(ser_ref);
11681         return (uint64_t)ret_conv;
11682 }
11683
11684 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
11685         LDKChannelMonitor this_obj_conv;
11686         this_obj_conv.inner = (void*)(this_obj & (~1));
11687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11688         ChannelMonitor_free(this_obj_conv);
11689 }
11690
11691 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
11692         LDKChannelMonitor orig_conv;
11693         orig_conv.inner = (void*)(orig & (~1));
11694         orig_conv.is_owned = false;
11695         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
11696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11698         uint64_t ret_ref = (uint64_t)ret_var.inner;
11699         if (ret_var.is_owned) {
11700                 ret_ref |= 1;
11701         }
11702         return ret_ref;
11703 }
11704
11705 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
11706         LDKChannelMonitor obj_conv;
11707         obj_conv.inner = (void*)(obj & (~1));
11708         obj_conv.is_owned = false;
11709         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
11710         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11711         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11712         CVec_u8Z_free(ret_var);
11713         return ret_arr;
11714 }
11715
11716 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) {
11717         LDKChannelMonitor this_arg_conv;
11718         this_arg_conv.inner = (void*)(this_arg & (~1));
11719         this_arg_conv.is_owned = false;
11720         LDKChannelMonitorUpdate updates_conv;
11721         updates_conv.inner = (void*)(updates & (~1));
11722         updates_conv.is_owned = false;
11723         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11724         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11725         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11726         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11727         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
11728         return (uint64_t)ret_conv;
11729 }
11730
11731 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
11732         LDKChannelMonitor this_arg_conv;
11733         this_arg_conv.inner = (void*)(this_arg & (~1));
11734         this_arg_conv.is_owned = false;
11735         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
11736         return ret_val;
11737 }
11738
11739 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
11740         LDKChannelMonitor this_arg_conv;
11741         this_arg_conv.inner = (void*)(this_arg & (~1));
11742         this_arg_conv.is_owned = false;
11743         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11744         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
11745         return (uint64_t)ret_ref;
11746 }
11747
11748 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
11749         LDKChannelMonitor this_arg_conv;
11750         this_arg_conv.inner = (void*)(this_arg & (~1));
11751         this_arg_conv.is_owned = false;
11752         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
11753         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11754         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11755         for (size_t c = 0; c < ret_var.datalen; c++) {
11756                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11757                 *ret_conv_54_ref = ret_var.data[c];
11758                 ret_arr_ptr[c] = (uint64_t)ret_conv_54_ref;
11759         }
11760         FREE(ret_var.data);
11761         return ret_arr;
11762 }
11763
11764 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
11765         LDKChannelMonitor this_arg_conv;
11766         this_arg_conv.inner = (void*)(this_arg & (~1));
11767         this_arg_conv.is_owned = false;
11768         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
11769         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
11770 }
11771
11772 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
11773         LDKChannelMonitor this_arg_conv;
11774         this_arg_conv.inner = (void*)(this_arg & (~1));
11775         this_arg_conv.is_owned = false;
11776         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
11777         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11778         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11779         for (size_t o = 0; o < ret_var.datalen; o++) {
11780                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
11781                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
11782                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
11783                 ret_arr_ptr[o] = ret_conv_14_ref;
11784         }
11785         FREE(ret_var.data);
11786         return ret_arr;
11787 }
11788
11789 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
11790         LDKChannelMonitor this_arg_conv;
11791         this_arg_conv.inner = (void*)(this_arg & (~1));
11792         this_arg_conv.is_owned = false;
11793         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
11794         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11795         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11796         for (size_t h = 0; h < ret_var.datalen; h++) {
11797                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11798                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
11799                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
11800                 ret_arr_ptr[h] = ret_conv_7_ref;
11801         }
11802         FREE(ret_var.data);
11803         return ret_arr;
11804 }
11805
11806 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
11807         LDKChannelMonitor this_arg_conv;
11808         this_arg_conv.inner = (void*)(this_arg & (~1));
11809         this_arg_conv.is_owned = false;
11810         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
11811         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
11812         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11813         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11814         for (size_t m = 0; m < ret_var.datalen; m++) {
11815                 LDKTransaction ret_conv_12_var = ret_var.data[m];
11816                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11817                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
11818                 Transaction_free(ret_conv_12_var);
11819                 ret_arr_ptr[m] = ret_conv_12_arr;
11820         }
11821         FREE(ret_var.data);
11822         return ret_arr;
11823 }
11824
11825 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) {
11826         LDKChannelMonitor this_arg_conv;
11827         this_arg_conv.inner = (void*)(this_arg & (~1));
11828         this_arg_conv.is_owned = false;
11829         unsigned char header_arr[80];
11830         CHECK(*((uint32_t*)header) == 80);
11831         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11832         unsigned char (*header_ref)[80] = &header_arr;
11833         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11834         txdata_constr.datalen = *((uint32_t*)txdata);
11835         if (txdata_constr.datalen > 0)
11836                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11837         else
11838                 txdata_constr.data = NULL;
11839         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11840         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11841                 uint32_t txdata_conv_30 = txdata_vals[e];
11842                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11843                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11844                 txdata_constr.data[e] = txdata_conv_30_conv;
11845         }
11846         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11847         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11848         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11849         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);
11850         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11851         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11852         for (size_t x = 0; x < ret_var.datalen; x++) {
11853                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11854                 *ret_conv_49_ref = ret_var.data[x];
11855                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11856         }
11857         FREE(ret_var.data);
11858         return ret_arr;
11859 }
11860
11861 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) {
11862         LDKChannelMonitor this_arg_conv;
11863         this_arg_conv.inner = (void*)(this_arg & (~1));
11864         this_arg_conv.is_owned = false;
11865         unsigned char header_arr[80];
11866         CHECK(*((uint32_t*)header) == 80);
11867         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11868         unsigned char (*header_ref)[80] = &header_arr;
11869         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11870         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11871         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11872         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11873 }
11874
11875 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) {
11876         LDKChannelMonitor this_arg_conv;
11877         this_arg_conv.inner = (void*)(this_arg & (~1));
11878         this_arg_conv.is_owned = false;
11879         unsigned char header_arr[80];
11880         CHECK(*((uint32_t*)header) == 80);
11881         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11882         unsigned char (*header_ref)[80] = &header_arr;
11883         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11884         txdata_constr.datalen = *((uint32_t*)txdata);
11885         if (txdata_constr.datalen > 0)
11886                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11887         else
11888                 txdata_constr.data = NULL;
11889         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11890         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11891                 uint32_t txdata_conv_30 = txdata_vals[e];
11892                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11893                 txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
11894                 txdata_constr.data[e] = txdata_conv_30_conv;
11895         }
11896         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11897         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11898         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11899         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);
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 x = 0; x < ret_var.datalen; x++) {
11903                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11904                 *ret_conv_49_ref = ret_var.data[x];
11905                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11906         }
11907         FREE(ret_var.data);
11908         return ret_arr;
11909 }
11910
11911 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) {
11912         LDKChannelMonitor this_arg_conv;
11913         this_arg_conv.inner = (void*)(this_arg & (~1));
11914         this_arg_conv.is_owned = false;
11915         unsigned char txid_arr[32];
11916         CHECK(*((uint32_t*)txid) == 32);
11917         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
11918         unsigned char (*txid_ref)[32] = &txid_arr;
11919         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11920         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11921         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11922         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
11923 }
11924
11925 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) {
11926         LDKChannelMonitor this_arg_conv;
11927         this_arg_conv.inner = (void*)(this_arg & (~1));
11928         this_arg_conv.is_owned = false;
11929         unsigned char header_arr[80];
11930         CHECK(*((uint32_t*)header) == 80);
11931         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11932         unsigned char (*header_ref)[80] = &header_arr;
11933         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
11934         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11935         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11936         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
11937         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
11938         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
11939         for (size_t x = 0; x < ret_var.datalen; x++) {
11940                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11941                 *ret_conv_49_ref = ret_var.data[x];
11942                 ret_arr_ptr[x] = (uint64_t)ret_conv_49_ref;
11943         }
11944         FREE(ret_var.data);
11945         return ret_arr;
11946 }
11947
11948 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
11949         LDKChannelMonitor this_arg_conv;
11950         this_arg_conv.inner = (void*)(this_arg & (~1));
11951         this_arg_conv.is_owned = false;
11952         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
11953         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
11954         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
11955         for (size_t m = 0; m < ret_var.datalen; m++) {
11956                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11957                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
11958                 ret_arr_ptr[m] = ret_conv_12_arr;
11959         }
11960         FREE(ret_var.data);
11961         return ret_arr;
11962 }
11963
11964 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
11965         if ((this_ptr & 1) != 0) return;
11966         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
11967         FREE((void*)this_ptr);
11968         Persist_free(this_ptr_conv);
11969 }
11970
11971 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
11972         LDKu8slice ser_ref;
11973         ser_ref.datalen = *((uint32_t*)ser);
11974         ser_ref.data = (int8_t*)(ser + 4);
11975         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
11976         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11977         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
11978         return (uint64_t)ret_conv;
11979 }
11980
11981 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
11982         LDKOutPoint this_obj_conv;
11983         this_obj_conv.inner = (void*)(this_obj & (~1));
11984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11985         OutPoint_free(this_obj_conv);
11986 }
11987
11988 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
11989         LDKOutPoint this_ptr_conv;
11990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11991         this_ptr_conv.is_owned = false;
11992         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11993         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
11994         return ret_arr;
11995 }
11996
11997 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
11998         LDKOutPoint this_ptr_conv;
11999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12000         this_ptr_conv.is_owned = false;
12001         LDKThirtyTwoBytes val_ref;
12002         CHECK(*((uint32_t*)val) == 32);
12003         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12004         OutPoint_set_txid(&this_ptr_conv, val_ref);
12005 }
12006
12007 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
12008         LDKOutPoint this_ptr_conv;
12009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12010         this_ptr_conv.is_owned = false;
12011         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
12012         return ret_val;
12013 }
12014
12015 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
12016         LDKOutPoint this_ptr_conv;
12017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12018         this_ptr_conv.is_owned = false;
12019         OutPoint_set_index(&this_ptr_conv, val);
12020 }
12021
12022 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
12023         LDKThirtyTwoBytes txid_arg_ref;
12024         CHECK(*((uint32_t*)txid_arg) == 32);
12025         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
12026         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
12027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12029         uint64_t ret_ref = (uint64_t)ret_var.inner;
12030         if (ret_var.is_owned) {
12031                 ret_ref |= 1;
12032         }
12033         return ret_ref;
12034 }
12035
12036 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
12037         LDKOutPoint orig_conv;
12038         orig_conv.inner = (void*)(orig & (~1));
12039         orig_conv.is_owned = false;
12040         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
12041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12043         uint64_t ret_ref = (uint64_t)ret_var.inner;
12044         if (ret_var.is_owned) {
12045                 ret_ref |= 1;
12046         }
12047         return ret_ref;
12048 }
12049
12050 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
12051         LDKOutPoint a_conv;
12052         a_conv.inner = (void*)(a & (~1));
12053         a_conv.is_owned = false;
12054         LDKOutPoint b_conv;
12055         b_conv.inner = (void*)(b & (~1));
12056         b_conv.is_owned = false;
12057         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
12058         return ret_val;
12059 }
12060
12061 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
12062         LDKOutPoint o_conv;
12063         o_conv.inner = (void*)(o & (~1));
12064         o_conv.is_owned = false;
12065         int64_t ret_val = OutPoint_hash(&o_conv);
12066         return ret_val;
12067 }
12068
12069 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
12070         LDKOutPoint this_arg_conv;
12071         this_arg_conv.inner = (void*)(this_arg & (~1));
12072         this_arg_conv.is_owned = false;
12073         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12074         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
12075         return ret_arr;
12076 }
12077
12078 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
12079         LDKOutPoint obj_conv;
12080         obj_conv.inner = (void*)(obj & (~1));
12081         obj_conv.is_owned = false;
12082         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
12083         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12084         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12085         CVec_u8Z_free(ret_var);
12086         return ret_arr;
12087 }
12088
12089 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
12090         LDKu8slice ser_ref;
12091         ser_ref.datalen = *((uint32_t*)ser);
12092         ser_ref.data = (int8_t*)(ser + 4);
12093         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12094         *ret_conv = OutPoint_read(ser_ref);
12095         return (uint64_t)ret_conv;
12096 }
12097
12098 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
12099         LDKDelayedPaymentOutputDescriptor this_obj_conv;
12100         this_obj_conv.inner = (void*)(this_obj & (~1));
12101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12102         DelayedPaymentOutputDescriptor_free(this_obj_conv);
12103 }
12104
12105 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12106         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12108         this_ptr_conv.is_owned = false;
12109         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12110         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12111         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12112         uint64_t ret_ref = (uint64_t)ret_var.inner;
12113         if (ret_var.is_owned) {
12114                 ret_ref |= 1;
12115         }
12116         return ret_ref;
12117 }
12118
12119 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12120         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12122         this_ptr_conv.is_owned = false;
12123         LDKOutPoint val_conv;
12124         val_conv.inner = (void*)(val & (~1));
12125         val_conv.is_owned = (val & 1) || (val == 0);
12126         val_conv = OutPoint_clone(&val_conv);
12127         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12128 }
12129
12130 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
12131         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12133         this_ptr_conv.is_owned = false;
12134         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12135         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12136         return ret_arr;
12137 }
12138
12139 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12140         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12142         this_ptr_conv.is_owned = false;
12143         LDKPublicKey val_ref;
12144         CHECK(*((uint32_t*)val) == 33);
12145         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12146         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
12147 }
12148
12149 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
12150         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12152         this_ptr_conv.is_owned = false;
12153         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
12154         return ret_val;
12155 }
12156
12157 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12158         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12160         this_ptr_conv.is_owned = false;
12161         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
12162 }
12163
12164 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12165         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12167         this_ptr_conv.is_owned = false;
12168         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12169         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12170 }
12171
12172 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
12173         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12175         this_ptr_conv.is_owned = false;
12176         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12177         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
12178         return ret_arr;
12179 }
12180
12181 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
12182         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12184         this_ptr_conv.is_owned = false;
12185         LDKPublicKey val_ref;
12186         CHECK(*((uint32_t*)val) == 33);
12187         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12188         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
12189 }
12190
12191 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12192         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12194         this_ptr_conv.is_owned = false;
12195         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12196         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12197         return ret_arr;
12198 }
12199
12200 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12201         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12203         this_ptr_conv.is_owned = false;
12204         LDKThirtyTwoBytes val_ref;
12205         CHECK(*((uint32_t*)val) == 32);
12206         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12207         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12208 }
12209
12210 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12211         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12213         this_ptr_conv.is_owned = false;
12214         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12215         return ret_val;
12216 }
12217
12218 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12219         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
12220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12221         this_ptr_conv.is_owned = false;
12222         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12223 }
12224
12225 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) {
12226         LDKOutPoint outpoint_arg_conv;
12227         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12228         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12229         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12230         LDKPublicKey per_commitment_point_arg_ref;
12231         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
12232         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
12233         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12234         LDKPublicKey revocation_pubkey_arg_ref;
12235         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
12236         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
12237         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12238         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12239         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12240         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);
12241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12243         uint64_t ret_ref = (uint64_t)ret_var.inner;
12244         if (ret_var.is_owned) {
12245                 ret_ref |= 1;
12246         }
12247         return ret_ref;
12248 }
12249
12250 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
12251         LDKDelayedPaymentOutputDescriptor orig_conv;
12252         orig_conv.inner = (void*)(orig & (~1));
12253         orig_conv.is_owned = false;
12254         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
12255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12257         uint64_t ret_ref = (uint64_t)ret_var.inner;
12258         if (ret_var.is_owned) {
12259                 ret_ref |= 1;
12260         }
12261         return ret_ref;
12262 }
12263
12264 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
12265         LDKDelayedPaymentOutputDescriptor obj_conv;
12266         obj_conv.inner = (void*)(obj & (~1));
12267         obj_conv.is_owned = false;
12268         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
12269         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12270         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12271         CVec_u8Z_free(ret_var);
12272         return ret_arr;
12273 }
12274
12275 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
12276         LDKu8slice ser_ref;
12277         ser_ref.datalen = *((uint32_t*)ser);
12278         ser_ref.data = (int8_t*)(ser + 4);
12279         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
12280         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
12281         return (uint64_t)ret_conv;
12282 }
12283
12284 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
12285         LDKStaticPaymentOutputDescriptor this_obj_conv;
12286         this_obj_conv.inner = (void*)(this_obj & (~1));
12287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12288         StaticPaymentOutputDescriptor_free(this_obj_conv);
12289 }
12290
12291 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
12292         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12294         this_ptr_conv.is_owned = false;
12295         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
12296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12298         uint64_t ret_ref = (uint64_t)ret_var.inner;
12299         if (ret_var.is_owned) {
12300                 ret_ref |= 1;
12301         }
12302         return ret_ref;
12303 }
12304
12305 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
12306         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12308         this_ptr_conv.is_owned = false;
12309         LDKOutPoint val_conv;
12310         val_conv.inner = (void*)(val & (~1));
12311         val_conv.is_owned = (val & 1) || (val == 0);
12312         val_conv = OutPoint_clone(&val_conv);
12313         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
12314 }
12315
12316 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
12317         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12319         this_ptr_conv.is_owned = false;
12320         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
12321         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
12322 }
12323
12324 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
12325         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12327         this_ptr_conv.is_owned = false;
12328         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12329         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
12330         return ret_arr;
12331 }
12332
12333 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
12334         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12336         this_ptr_conv.is_owned = false;
12337         LDKThirtyTwoBytes val_ref;
12338         CHECK(*((uint32_t*)val) == 32);
12339         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12340         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
12341 }
12342
12343 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
12344         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12346         this_ptr_conv.is_owned = false;
12347         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
12348         return ret_val;
12349 }
12350
12351 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
12352         LDKStaticPaymentOutputDescriptor this_ptr_conv;
12353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12354         this_ptr_conv.is_owned = false;
12355         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
12356 }
12357
12358 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) {
12359         LDKOutPoint outpoint_arg_conv;
12360         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
12361         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
12362         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
12363         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
12364         LDKThirtyTwoBytes channel_keys_id_arg_ref;
12365         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
12366         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
12367         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
12368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12370         uint64_t ret_ref = (uint64_t)ret_var.inner;
12371         if (ret_var.is_owned) {
12372                 ret_ref |= 1;
12373         }
12374         return ret_ref;
12375 }
12376
12377 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
12378         LDKStaticPaymentOutputDescriptor orig_conv;
12379         orig_conv.inner = (void*)(orig & (~1));
12380         orig_conv.is_owned = false;
12381         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
12382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12384         uint64_t ret_ref = (uint64_t)ret_var.inner;
12385         if (ret_var.is_owned) {
12386                 ret_ref |= 1;
12387         }
12388         return ret_ref;
12389 }
12390
12391 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
12392         LDKStaticPaymentOutputDescriptor obj_conv;
12393         obj_conv.inner = (void*)(obj & (~1));
12394         obj_conv.is_owned = false;
12395         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
12396         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12397         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12398         CVec_u8Z_free(ret_var);
12399         return ret_arr;
12400 }
12401
12402 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
12403         LDKu8slice ser_ref;
12404         ser_ref.datalen = *((uint32_t*)ser);
12405         ser_ref.data = (int8_t*)(ser + 4);
12406         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
12407         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
12408         return (uint64_t)ret_conv;
12409 }
12410
12411 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
12412         if ((this_ptr & 1) != 0) return;
12413         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
12414         FREE((void*)this_ptr);
12415         SpendableOutputDescriptor_free(this_ptr_conv);
12416 }
12417
12418 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
12419         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
12420         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
12421         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
12422         uint64_t ret_ref = (uint64_t)ret_copy;
12423         return ret_ref;
12424 }
12425
12426 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
12427         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
12428         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
12429         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12430         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12431         CVec_u8Z_free(ret_var);
12432         return ret_arr;
12433 }
12434
12435 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
12436         LDKu8slice ser_ref;
12437         ser_ref.datalen = *((uint32_t*)ser);
12438         ser_ref.data = (int8_t*)(ser + 4);
12439         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
12440         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
12441         return (uint64_t)ret_conv;
12442 }
12443
12444 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
12445         if ((this_ptr & 1) != 0) return;
12446         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
12447         FREE((void*)this_ptr);
12448         BaseSign_free(this_ptr_conv);
12449 }
12450
12451 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
12452         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
12453         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12454         *ret = Sign_clone(orig_conv);
12455         return (uint64_t)ret;
12456 }
12457
12458 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
12459         if ((this_ptr & 1) != 0) return;
12460         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
12461         FREE((void*)this_ptr);
12462         Sign_free(this_ptr_conv);
12463 }
12464
12465 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
12466         if ((this_ptr & 1) != 0) return;
12467         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
12468         FREE((void*)this_ptr);
12469         KeysInterface_free(this_ptr_conv);
12470 }
12471
12472 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
12473         LDKInMemorySigner this_obj_conv;
12474         this_obj_conv.inner = (void*)(this_obj & (~1));
12475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12476         InMemorySigner_free(this_obj_conv);
12477 }
12478
12479 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
12480         LDKInMemorySigner this_ptr_conv;
12481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12482         this_ptr_conv.is_owned = false;
12483         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12484         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
12485         return ret_arr;
12486 }
12487
12488 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
12489         LDKInMemorySigner this_ptr_conv;
12490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12491         this_ptr_conv.is_owned = false;
12492         LDKSecretKey val_ref;
12493         CHECK(*((uint32_t*)val) == 32);
12494         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12495         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
12496 }
12497
12498 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
12499         LDKInMemorySigner this_ptr_conv;
12500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12501         this_ptr_conv.is_owned = false;
12502         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12503         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
12504         return ret_arr;
12505 }
12506
12507 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
12508         LDKInMemorySigner this_ptr_conv;
12509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12510         this_ptr_conv.is_owned = false;
12511         LDKSecretKey val_ref;
12512         CHECK(*((uint32_t*)val) == 32);
12513         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12514         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
12515 }
12516
12517 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
12518         LDKInMemorySigner this_ptr_conv;
12519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12520         this_ptr_conv.is_owned = false;
12521         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12522         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
12523         return ret_arr;
12524 }
12525
12526 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
12527         LDKInMemorySigner this_ptr_conv;
12528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12529         this_ptr_conv.is_owned = false;
12530         LDKSecretKey val_ref;
12531         CHECK(*((uint32_t*)val) == 32);
12532         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12533         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
12534 }
12535
12536 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
12537         LDKInMemorySigner this_ptr_conv;
12538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12539         this_ptr_conv.is_owned = false;
12540         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12541         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
12542         return ret_arr;
12543 }
12544
12545 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
12546         LDKInMemorySigner this_ptr_conv;
12547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12548         this_ptr_conv.is_owned = false;
12549         LDKSecretKey val_ref;
12550         CHECK(*((uint32_t*)val) == 32);
12551         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12552         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
12553 }
12554
12555 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
12556         LDKInMemorySigner this_ptr_conv;
12557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12558         this_ptr_conv.is_owned = false;
12559         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12560         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
12561         return ret_arr;
12562 }
12563
12564 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
12565         LDKInMemorySigner this_ptr_conv;
12566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12567         this_ptr_conv.is_owned = false;
12568         LDKSecretKey val_ref;
12569         CHECK(*((uint32_t*)val) == 32);
12570         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
12571         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
12572 }
12573
12574 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
12575         LDKInMemorySigner this_ptr_conv;
12576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12577         this_ptr_conv.is_owned = false;
12578         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12579         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
12580         return ret_arr;
12581 }
12582
12583 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
12584         LDKInMemorySigner this_ptr_conv;
12585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12586         this_ptr_conv.is_owned = false;
12587         LDKThirtyTwoBytes val_ref;
12588         CHECK(*((uint32_t*)val) == 32);
12589         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12590         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
12591 }
12592
12593 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
12594         LDKInMemorySigner orig_conv;
12595         orig_conv.inner = (void*)(orig & (~1));
12596         orig_conv.is_owned = false;
12597         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
12598         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12599         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12600         uint64_t ret_ref = (uint64_t)ret_var.inner;
12601         if (ret_var.is_owned) {
12602                 ret_ref |= 1;
12603         }
12604         return ret_ref;
12605 }
12606
12607 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) {
12608         LDKSecretKey funding_key_ref;
12609         CHECK(*((uint32_t*)funding_key) == 32);
12610         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
12611         LDKSecretKey revocation_base_key_ref;
12612         CHECK(*((uint32_t*)revocation_base_key) == 32);
12613         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
12614         LDKSecretKey payment_key_ref;
12615         CHECK(*((uint32_t*)payment_key) == 32);
12616         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
12617         LDKSecretKey delayed_payment_base_key_ref;
12618         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
12619         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
12620         LDKSecretKey htlc_base_key_ref;
12621         CHECK(*((uint32_t*)htlc_base_key) == 32);
12622         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
12623         LDKThirtyTwoBytes commitment_seed_ref;
12624         CHECK(*((uint32_t*)commitment_seed) == 32);
12625         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
12626         LDKThirtyTwoBytes channel_keys_id_ref;
12627         CHECK(*((uint32_t*)channel_keys_id) == 32);
12628         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
12629         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);
12630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12632         uint64_t ret_ref = (uint64_t)ret_var.inner;
12633         if (ret_var.is_owned) {
12634                 ret_ref |= 1;
12635         }
12636         return ret_ref;
12637 }
12638
12639 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
12640         LDKInMemorySigner this_arg_conv;
12641         this_arg_conv.inner = (void*)(this_arg & (~1));
12642         this_arg_conv.is_owned = false;
12643         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
12644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12646         uint64_t ret_ref = (uint64_t)ret_var.inner;
12647         if (ret_var.is_owned) {
12648                 ret_ref |= 1;
12649         }
12650         return ret_ref;
12651 }
12652
12653 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
12654         LDKInMemorySigner this_arg_conv;
12655         this_arg_conv.inner = (void*)(this_arg & (~1));
12656         this_arg_conv.is_owned = false;
12657         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
12658         return ret_val;
12659 }
12660
12661 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
12662         LDKInMemorySigner this_arg_conv;
12663         this_arg_conv.inner = (void*)(this_arg & (~1));
12664         this_arg_conv.is_owned = false;
12665         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
12666         return ret_val;
12667 }
12668
12669 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
12670         LDKInMemorySigner this_arg_conv;
12671         this_arg_conv.inner = (void*)(this_arg & (~1));
12672         this_arg_conv.is_owned = false;
12673         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
12674         return ret_val;
12675 }
12676
12677 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
12678         LDKInMemorySigner this_arg_conv;
12679         this_arg_conv.inner = (void*)(this_arg & (~1));
12680         this_arg_conv.is_owned = false;
12681         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
12682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12684         uint64_t ret_ref = (uint64_t)ret_var.inner;
12685         if (ret_var.is_owned) {
12686                 ret_ref |= 1;
12687         }
12688         return ret_ref;
12689 }
12690
12691 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
12692         LDKInMemorySigner this_arg_conv;
12693         this_arg_conv.inner = (void*)(this_arg & (~1));
12694         this_arg_conv.is_owned = false;
12695         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
12696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12698         uint64_t ret_ref = (uint64_t)ret_var.inner;
12699         if (ret_var.is_owned) {
12700                 ret_ref |= 1;
12701         }
12702         return ret_ref;
12703 }
12704
12705 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) {
12706         LDKInMemorySigner this_arg_conv;
12707         this_arg_conv.inner = (void*)(this_arg & (~1));
12708         this_arg_conv.is_owned = false;
12709         LDKTransaction spend_tx_ref;
12710         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12711         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12712         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12713         spend_tx_ref.data_is_owned = true;
12714         LDKStaticPaymentOutputDescriptor descriptor_conv;
12715         descriptor_conv.inner = (void*)(descriptor & (~1));
12716         descriptor_conv.is_owned = false;
12717         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12718         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12719         return (uint64_t)ret_conv;
12720 }
12721
12722 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) {
12723         LDKInMemorySigner this_arg_conv;
12724         this_arg_conv.inner = (void*)(this_arg & (~1));
12725         this_arg_conv.is_owned = false;
12726         LDKTransaction spend_tx_ref;
12727         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
12728         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
12729         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
12730         spend_tx_ref.data_is_owned = true;
12731         LDKDelayedPaymentOutputDescriptor descriptor_conv;
12732         descriptor_conv.inner = (void*)(descriptor & (~1));
12733         descriptor_conv.is_owned = false;
12734         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
12735         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
12736         return (uint64_t)ret_conv;
12737 }
12738
12739 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
12740         LDKInMemorySigner this_arg_conv;
12741         this_arg_conv.inner = (void*)(this_arg & (~1));
12742         this_arg_conv.is_owned = false;
12743         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
12744         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
12745         return (uint64_t)ret;
12746 }
12747
12748 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
12749         LDKInMemorySigner this_arg_conv;
12750         this_arg_conv.inner = (void*)(this_arg & (~1));
12751         this_arg_conv.is_owned = false;
12752         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
12753         *ret = InMemorySigner_as_Sign(&this_arg_conv);
12754         return (uint64_t)ret;
12755 }
12756
12757 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
12758         LDKInMemorySigner obj_conv;
12759         obj_conv.inner = (void*)(obj & (~1));
12760         obj_conv.is_owned = false;
12761         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
12762         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12763         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12764         CVec_u8Z_free(ret_var);
12765         return ret_arr;
12766 }
12767
12768 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
12769         LDKu8slice ser_ref;
12770         ser_ref.datalen = *((uint32_t*)ser);
12771         ser_ref.data = (int8_t*)(ser + 4);
12772         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
12773         *ret_conv = InMemorySigner_read(ser_ref);
12774         return (uint64_t)ret_conv;
12775 }
12776
12777 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
12778         LDKKeysManager this_obj_conv;
12779         this_obj_conv.inner = (void*)(this_obj & (~1));
12780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12781         KeysManager_free(this_obj_conv);
12782 }
12783
12784 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
12785         unsigned char seed_arr[32];
12786         CHECK(*((uint32_t*)seed) == 32);
12787         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
12788         unsigned char (*seed_ref)[32] = &seed_arr;
12789         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
12790         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12791         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12792         uint64_t ret_ref = (uint64_t)ret_var.inner;
12793         if (ret_var.is_owned) {
12794                 ret_ref |= 1;
12795         }
12796         return ret_ref;
12797 }
12798
12799 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
12800         LDKKeysManager this_arg_conv;
12801         this_arg_conv.inner = (void*)(this_arg & (~1));
12802         this_arg_conv.is_owned = false;
12803         unsigned char params_arr[32];
12804         CHECK(*((uint32_t*)params) == 32);
12805         memcpy(params_arr, (uint8_t*)(params + 4), 32);
12806         unsigned char (*params_ref)[32] = &params_arr;
12807         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
12808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12810         uint64_t ret_ref = (uint64_t)ret_var.inner;
12811         if (ret_var.is_owned) {
12812                 ret_ref |= 1;
12813         }
12814         return ret_ref;
12815 }
12816
12817 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) {
12818         LDKKeysManager this_arg_conv;
12819         this_arg_conv.inner = (void*)(this_arg & (~1));
12820         this_arg_conv.is_owned = false;
12821         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
12822         descriptors_constr.datalen = *((uint32_t*)descriptors);
12823         if (descriptors_constr.datalen > 0)
12824                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12825         else
12826                 descriptors_constr.data = NULL;
12827         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
12828         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
12829                 uint32_t descriptors_conv_27 = descriptors_vals[b];
12830                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
12831                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
12832                 descriptors_constr.data[b] = descriptors_conv_27_conv;
12833         }
12834         LDKCVec_TxOutZ outputs_constr;
12835         outputs_constr.datalen = *((uint32_t*)outputs);
12836         if (outputs_constr.datalen > 0)
12837                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
12838         else
12839                 outputs_constr.data = NULL;
12840         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
12841         for (size_t h = 0; h < outputs_constr.datalen; h++) {
12842                 uint32_t outputs_conv_7 = outputs_vals[h];
12843                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
12844                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
12845                 outputs_constr.data[h] = outputs_conv_7_conv;
12846         }
12847         LDKCVec_u8Z change_destination_script_ref;
12848         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
12849         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
12850         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
12851         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
12852         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
12853         return (uint64_t)ret_conv;
12854 }
12855
12856 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
12857         LDKKeysManager this_arg_conv;
12858         this_arg_conv.inner = (void*)(this_arg & (~1));
12859         this_arg_conv.is_owned = false;
12860         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
12861         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
12862         return (uint64_t)ret;
12863 }
12864
12865 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
12866         LDKChannelManager this_obj_conv;
12867         this_obj_conv.inner = (void*)(this_obj & (~1));
12868         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12869         ChannelManager_free(this_obj_conv);
12870 }
12871
12872 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
12873         LDKChainParameters this_obj_conv;
12874         this_obj_conv.inner = (void*)(this_obj & (~1));
12875         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12876         ChainParameters_free(this_obj_conv);
12877 }
12878
12879 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
12880         LDKChainParameters this_ptr_conv;
12881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12882         this_ptr_conv.is_owned = false;
12883         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
12884         return ret_conv;
12885 }
12886
12887 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
12888         LDKChainParameters this_ptr_conv;
12889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12890         this_ptr_conv.is_owned = false;
12891         LDKNetwork val_conv = LDKNetwork_from_js(val);
12892         ChainParameters_set_network(&this_ptr_conv, val_conv);
12893 }
12894
12895 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
12896         LDKChainParameters this_ptr_conv;
12897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12898         this_ptr_conv.is_owned = false;
12899         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
12900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12902         uint64_t ret_ref = (uint64_t)ret_var.inner;
12903         if (ret_var.is_owned) {
12904                 ret_ref |= 1;
12905         }
12906         return ret_ref;
12907 }
12908
12909 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
12910         LDKChainParameters this_ptr_conv;
12911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12912         this_ptr_conv.is_owned = false;
12913         LDKBestBlock val_conv;
12914         val_conv.inner = (void*)(val & (~1));
12915         val_conv.is_owned = (val & 1) || (val == 0);
12916         val_conv = BestBlock_clone(&val_conv);
12917         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
12918 }
12919
12920 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
12921         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
12922         LDKBestBlock best_block_arg_conv;
12923         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
12924         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
12925         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
12926         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
12927         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12928         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12929         uint64_t ret_ref = (uint64_t)ret_var.inner;
12930         if (ret_var.is_owned) {
12931                 ret_ref |= 1;
12932         }
12933         return ret_ref;
12934 }
12935
12936 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
12937         LDKChainParameters orig_conv;
12938         orig_conv.inner = (void*)(orig & (~1));
12939         orig_conv.is_owned = false;
12940         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
12941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12943         uint64_t ret_ref = (uint64_t)ret_var.inner;
12944         if (ret_var.is_owned) {
12945                 ret_ref |= 1;
12946         }
12947         return ret_ref;
12948 }
12949
12950 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
12951         LDKBestBlock this_obj_conv;
12952         this_obj_conv.inner = (void*)(this_obj & (~1));
12953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12954         BestBlock_free(this_obj_conv);
12955 }
12956
12957 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
12958         LDKBestBlock orig_conv;
12959         orig_conv.inner = (void*)(orig & (~1));
12960         orig_conv.is_owned = false;
12961         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
12962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12964         uint64_t ret_ref = (uint64_t)ret_var.inner;
12965         if (ret_var.is_owned) {
12966                 ret_ref |= 1;
12967         }
12968         return ret_ref;
12969 }
12970
12971 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
12972         LDKNetwork network_conv = LDKNetwork_from_js(network);
12973         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
12974         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12975         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12976         uint64_t ret_ref = (uint64_t)ret_var.inner;
12977         if (ret_var.is_owned) {
12978                 ret_ref |= 1;
12979         }
12980         return ret_ref;
12981 }
12982
12983 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
12984         LDKThirtyTwoBytes block_hash_ref;
12985         CHECK(*((uint32_t*)block_hash) == 32);
12986         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
12987         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
12988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12990         uint64_t ret_ref = (uint64_t)ret_var.inner;
12991         if (ret_var.is_owned) {
12992                 ret_ref |= 1;
12993         }
12994         return ret_ref;
12995 }
12996
12997 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
12998         LDKBestBlock this_arg_conv;
12999         this_arg_conv.inner = (void*)(this_arg & (~1));
13000         this_arg_conv.is_owned = false;
13001         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13002         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
13003         return ret_arr;
13004 }
13005
13006 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
13007         LDKBestBlock this_arg_conv;
13008         this_arg_conv.inner = (void*)(this_arg & (~1));
13009         this_arg_conv.is_owned = false;
13010         int32_t ret_val = BestBlock_height(&this_arg_conv);
13011         return ret_val;
13012 }
13013
13014 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
13015         LDKChannelDetails this_obj_conv;
13016         this_obj_conv.inner = (void*)(this_obj & (~1));
13017         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13018         ChannelDetails_free(this_obj_conv);
13019 }
13020
13021 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
13022         LDKChannelDetails this_ptr_conv;
13023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13024         this_ptr_conv.is_owned = false;
13025         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13026         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
13027         return ret_arr;
13028 }
13029
13030 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13031         LDKChannelDetails this_ptr_conv;
13032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13033         this_ptr_conv.is_owned = false;
13034         LDKThirtyTwoBytes val_ref;
13035         CHECK(*((uint32_t*)val) == 32);
13036         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13037         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
13038 }
13039
13040 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
13041         LDKChannelDetails this_ptr_conv;
13042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13043         this_ptr_conv.is_owned = false;
13044         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
13045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13047         uint64_t ret_ref = (uint64_t)ret_var.inner;
13048         if (ret_var.is_owned) {
13049                 ret_ref |= 1;
13050         }
13051         return ret_ref;
13052 }
13053
13054 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
13055         LDKChannelDetails this_ptr_conv;
13056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13057         this_ptr_conv.is_owned = false;
13058         LDKOutPoint val_conv;
13059         val_conv.inner = (void*)(val & (~1));
13060         val_conv.is_owned = (val & 1) || (val == 0);
13061         val_conv = OutPoint_clone(&val_conv);
13062         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
13063 }
13064
13065 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
13066         LDKChannelDetails this_ptr_conv;
13067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13068         this_ptr_conv.is_owned = false;
13069         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
13070         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
13071         uint64_t ret_ref = (uint64_t)ret_copy;
13072         return ret_ref;
13073 }
13074
13075 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
13076         LDKChannelDetails this_ptr_conv;
13077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13078         this_ptr_conv.is_owned = false;
13079         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
13080         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
13081 }
13082
13083 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
13084         LDKChannelDetails this_ptr_conv;
13085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13086         this_ptr_conv.is_owned = false;
13087         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13088         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
13089         return ret_arr;
13090 }
13091
13092 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
13093         LDKChannelDetails this_ptr_conv;
13094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13095         this_ptr_conv.is_owned = false;
13096         LDKPublicKey val_ref;
13097         CHECK(*((uint32_t*)val) == 33);
13098         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13099         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
13100 }
13101
13102 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
13103         LDKChannelDetails this_ptr_conv;
13104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13105         this_ptr_conv.is_owned = false;
13106         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
13107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13109         uint64_t ret_ref = (uint64_t)ret_var.inner;
13110         if (ret_var.is_owned) {
13111                 ret_ref |= 1;
13112         }
13113         return ret_ref;
13114 }
13115
13116 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
13117         LDKChannelDetails this_ptr_conv;
13118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13119         this_ptr_conv.is_owned = false;
13120         LDKInitFeatures val_conv;
13121         val_conv.inner = (void*)(val & (~1));
13122         val_conv.is_owned = (val & 1) || (val == 0);
13123         val_conv = InitFeatures_clone(&val_conv);
13124         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
13125 }
13126
13127 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
13128         LDKChannelDetails this_ptr_conv;
13129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13130         this_ptr_conv.is_owned = false;
13131         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
13132         return ret_val;
13133 }
13134
13135 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
13136         LDKChannelDetails this_ptr_conv;
13137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13138         this_ptr_conv.is_owned = false;
13139         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
13140 }
13141
13142 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
13143         LDKChannelDetails this_ptr_conv;
13144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13145         this_ptr_conv.is_owned = false;
13146         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
13147         return ret_val;
13148 }
13149
13150 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
13151         LDKChannelDetails this_ptr_conv;
13152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13153         this_ptr_conv.is_owned = false;
13154         ChannelDetails_set_user_id(&this_ptr_conv, val);
13155 }
13156
13157 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
13158         LDKChannelDetails this_ptr_conv;
13159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13160         this_ptr_conv.is_owned = false;
13161         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
13162         return ret_val;
13163 }
13164
13165 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13166         LDKChannelDetails this_ptr_conv;
13167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13168         this_ptr_conv.is_owned = false;
13169         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
13170 }
13171
13172 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
13173         LDKChannelDetails this_ptr_conv;
13174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13175         this_ptr_conv.is_owned = false;
13176         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
13177         return ret_val;
13178 }
13179
13180 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
13181         LDKChannelDetails this_ptr_conv;
13182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13183         this_ptr_conv.is_owned = false;
13184         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
13185 }
13186
13187 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
13188         LDKChannelDetails this_ptr_conv;
13189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13190         this_ptr_conv.is_owned = false;
13191         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
13192         return ret_val;
13193 }
13194
13195 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
13196         LDKChannelDetails this_ptr_conv;
13197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13198         this_ptr_conv.is_owned = false;
13199         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
13200 }
13201
13202 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
13203         LDKChannelDetails this_ptr_conv;
13204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13205         this_ptr_conv.is_owned = false;
13206         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
13207         return ret_val;
13208 }
13209
13210 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
13211         LDKChannelDetails this_ptr_conv;
13212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13213         this_ptr_conv.is_owned = false;
13214         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
13215 }
13216
13217 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(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         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
13222         return ret_val;
13223 }
13224
13225 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
13226         LDKChannelDetails this_ptr_conv;
13227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13228         this_ptr_conv.is_owned = false;
13229         ChannelDetails_set_is_usable(&this_ptr_conv, val);
13230 }
13231
13232 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
13233         LDKChannelDetails this_ptr_conv;
13234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13235         this_ptr_conv.is_owned = false;
13236         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
13237         return ret_val;
13238 }
13239
13240 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
13241         LDKChannelDetails this_ptr_conv;
13242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13243         this_ptr_conv.is_owned = false;
13244         ChannelDetails_set_is_public(&this_ptr_conv, val);
13245 }
13246
13247 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
13248         LDKChannelDetails orig_conv;
13249         orig_conv.inner = (void*)(orig & (~1));
13250         orig_conv.is_owned = false;
13251         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
13252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13254         uint64_t ret_ref = (uint64_t)ret_var.inner;
13255         if (ret_var.is_owned) {
13256                 ret_ref |= 1;
13257         }
13258         return ret_ref;
13259 }
13260
13261 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
13262         if ((this_ptr & 1) != 0) return;
13263         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
13264         FREE((void*)this_ptr);
13265         PaymentSendFailure_free(this_ptr_conv);
13266 }
13267
13268 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
13269         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
13270         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
13271         *ret_copy = PaymentSendFailure_clone(orig_conv);
13272         uint64_t ret_ref = (uint64_t)ret_copy;
13273         return ret_ref;
13274 }
13275
13276 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) {
13277         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
13278         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13279         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13280         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13281         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13282         LDKUserConfig config_conv;
13283         config_conv.inner = (void*)(config & (~1));
13284         config_conv.is_owned = (config & 1) || (config == 0);
13285         config_conv = UserConfig_clone(&config_conv);
13286         LDKChainParameters params_conv;
13287         params_conv.inner = (void*)(params & (~1));
13288         params_conv.is_owned = (params & 1) || (params == 0);
13289         params_conv = ChainParameters_clone(&params_conv);
13290         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
13291         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13292         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13293         uint64_t ret_ref = (uint64_t)ret_var.inner;
13294         if (ret_var.is_owned) {
13295                 ret_ref |= 1;
13296         }
13297         return ret_ref;
13298 }
13299
13300 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
13301         LDKChannelManager this_arg_conv;
13302         this_arg_conv.inner = (void*)(this_arg & (~1));
13303         this_arg_conv.is_owned = false;
13304         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
13305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13307         uint64_t ret_ref = (uint64_t)ret_var.inner;
13308         if (ret_var.is_owned) {
13309                 ret_ref |= 1;
13310         }
13311         return ret_ref;
13312 }
13313
13314 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) {
13315         LDKChannelManager this_arg_conv;
13316         this_arg_conv.inner = (void*)(this_arg & (~1));
13317         this_arg_conv.is_owned = false;
13318         LDKPublicKey their_network_key_ref;
13319         CHECK(*((uint32_t*)their_network_key) == 33);
13320         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
13321         LDKUserConfig override_config_conv;
13322         override_config_conv.inner = (void*)(override_config & (~1));
13323         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
13324         override_config_conv = UserConfig_clone(&override_config_conv);
13325         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13326         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
13327         return (uint64_t)ret_conv;
13328 }
13329
13330 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
13331         LDKChannelManager this_arg_conv;
13332         this_arg_conv.inner = (void*)(this_arg & (~1));
13333         this_arg_conv.is_owned = false;
13334         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
13335         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13336         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13337         for (size_t q = 0; q < ret_var.datalen; q++) {
13338                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13339                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13340                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13341                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13342                 if (ret_conv_16_var.is_owned) {
13343                         ret_conv_16_ref |= 1;
13344                 }
13345                 ret_arr_ptr[q] = ret_conv_16_ref;
13346         }
13347         FREE(ret_var.data);
13348         return ret_arr;
13349 }
13350
13351 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
13352         LDKChannelManager this_arg_conv;
13353         this_arg_conv.inner = (void*)(this_arg & (~1));
13354         this_arg_conv.is_owned = false;
13355         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
13356         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13357         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13358         for (size_t q = 0; q < ret_var.datalen; q++) {
13359                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13360                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13361                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13362                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
13363                 if (ret_conv_16_var.is_owned) {
13364                         ret_conv_16_ref |= 1;
13365                 }
13366                 ret_arr_ptr[q] = ret_conv_16_ref;
13367         }
13368         FREE(ret_var.data);
13369         return ret_arr;
13370 }
13371
13372 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13373         LDKChannelManager this_arg_conv;
13374         this_arg_conv.inner = (void*)(this_arg & (~1));
13375         this_arg_conv.is_owned = false;
13376         unsigned char channel_id_arr[32];
13377         CHECK(*((uint32_t*)channel_id) == 32);
13378         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13379         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13380         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13381         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
13382         return (uint64_t)ret_conv;
13383 }
13384
13385 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
13386         LDKChannelManager this_arg_conv;
13387         this_arg_conv.inner = (void*)(this_arg & (~1));
13388         this_arg_conv.is_owned = false;
13389         unsigned char channel_id_arr[32];
13390         CHECK(*((uint32_t*)channel_id) == 32);
13391         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
13392         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
13393         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13394         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
13395         return (uint64_t)ret_conv;
13396 }
13397
13398 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
13399         LDKChannelManager this_arg_conv;
13400         this_arg_conv.inner = (void*)(this_arg & (~1));
13401         this_arg_conv.is_owned = false;
13402         ChannelManager_force_close_all_channels(&this_arg_conv);
13403 }
13404
13405 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
13406         LDKChannelManager this_arg_conv;
13407         this_arg_conv.inner = (void*)(this_arg & (~1));
13408         this_arg_conv.is_owned = false;
13409         LDKRoute route_conv;
13410         route_conv.inner = (void*)(route & (~1));
13411         route_conv.is_owned = false;
13412         LDKThirtyTwoBytes payment_hash_ref;
13413         CHECK(*((uint32_t*)payment_hash) == 32);
13414         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13415         LDKThirtyTwoBytes payment_secret_ref;
13416         CHECK(*((uint32_t*)payment_secret) == 32);
13417         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
13418         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13419         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
13420         return (uint64_t)ret_conv;
13421 }
13422
13423 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
13424         LDKChannelManager this_arg_conv;
13425         this_arg_conv.inner = (void*)(this_arg & (~1));
13426         this_arg_conv.is_owned = false;
13427         unsigned char temporary_channel_id_arr[32];
13428         CHECK(*((uint32_t*)temporary_channel_id) == 32);
13429         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
13430         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
13431         LDKTransaction funding_transaction_ref;
13432         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
13433         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
13434         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
13435         funding_transaction_ref.data_is_owned = true;
13436         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13437         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
13438         return (uint64_t)ret_conv;
13439 }
13440
13441 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
13442         LDKChannelManager this_arg_conv;
13443         this_arg_conv.inner = (void*)(this_arg & (~1));
13444         this_arg_conv.is_owned = false;
13445         LDKThreeBytes rgb_ref;
13446         CHECK(*((uint32_t*)rgb) == 3);
13447         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
13448         LDKThirtyTwoBytes alias_ref;
13449         CHECK(*((uint32_t*)alias) == 32);
13450         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
13451         LDKCVec_NetAddressZ addresses_constr;
13452         addresses_constr.datalen = *((uint32_t*)addresses);
13453         if (addresses_constr.datalen > 0)
13454                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13455         else
13456                 addresses_constr.data = NULL;
13457         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
13458         for (size_t m = 0; m < addresses_constr.datalen; m++) {
13459                 uint32_t addresses_conv_12 = addresses_vals[m];
13460                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
13461                 addresses_constr.data[m] = addresses_conv_12_conv;
13462         }
13463         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
13464 }
13465
13466 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
13467         LDKChannelManager this_arg_conv;
13468         this_arg_conv.inner = (void*)(this_arg & (~1));
13469         this_arg_conv.is_owned = false;
13470         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
13471 }
13472
13473 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
13474         LDKChannelManager this_arg_conv;
13475         this_arg_conv.inner = (void*)(this_arg & (~1));
13476         this_arg_conv.is_owned = false;
13477         ChannelManager_timer_tick_occurred(&this_arg_conv);
13478 }
13479
13480 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
13481         LDKChannelManager this_arg_conv;
13482         this_arg_conv.inner = (void*)(this_arg & (~1));
13483         this_arg_conv.is_owned = false;
13484         unsigned char payment_hash_arr[32];
13485         CHECK(*((uint32_t*)payment_hash) == 32);
13486         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
13487         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13488         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
13489         return ret_val;
13490 }
13491
13492 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
13493         LDKChannelManager this_arg_conv;
13494         this_arg_conv.inner = (void*)(this_arg & (~1));
13495         this_arg_conv.is_owned = false;
13496         LDKThirtyTwoBytes payment_preimage_ref;
13497         CHECK(*((uint32_t*)payment_preimage) == 32);
13498         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
13499         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
13500         return ret_val;
13501 }
13502
13503 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
13504         LDKChannelManager this_arg_conv;
13505         this_arg_conv.inner = (void*)(this_arg & (~1));
13506         this_arg_conv.is_owned = false;
13507         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13508         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
13509         return ret_arr;
13510 }
13511
13512 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
13513         LDKChannelManager this_arg_conv;
13514         this_arg_conv.inner = (void*)(this_arg & (~1));
13515         this_arg_conv.is_owned = false;
13516         LDKOutPoint funding_txo_conv;
13517         funding_txo_conv.inner = (void*)(funding_txo & (~1));
13518         funding_txo_conv.is_owned = false;
13519         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
13520 }
13521
13522 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) {
13523         LDKChannelManager this_arg_conv;
13524         this_arg_conv.inner = (void*)(this_arg & (~1));
13525         this_arg_conv.is_owned = false;
13526         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13527         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
13528         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
13529         return (uint64_t)ret_ref;
13530 }
13531
13532 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) {
13533         LDKChannelManager this_arg_conv;
13534         this_arg_conv.inner = (void*)(this_arg & (~1));
13535         this_arg_conv.is_owned = false;
13536         LDKThirtyTwoBytes payment_hash_ref;
13537         CHECK(*((uint32_t*)payment_hash) == 32);
13538         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
13539         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
13540         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
13541         *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);
13542         return (uint64_t)ret_conv;
13543 }
13544
13545 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
13546         LDKChannelManager this_arg_conv;
13547         this_arg_conv.inner = (void*)(this_arg & (~1));
13548         this_arg_conv.is_owned = false;
13549         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13550         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
13551         return (uint64_t)ret;
13552 }
13553
13554 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
13555         LDKChannelManager this_arg_conv;
13556         this_arg_conv.inner = (void*)(this_arg & (~1));
13557         this_arg_conv.is_owned = false;
13558         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13559         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
13560         return (uint64_t)ret;
13561 }
13562
13563 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
13564         LDKChannelManager this_arg_conv;
13565         this_arg_conv.inner = (void*)(this_arg & (~1));
13566         this_arg_conv.is_owned = false;
13567         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
13568         *ret = ChannelManager_as_Listen(&this_arg_conv);
13569         return (uint64_t)ret;
13570 }
13571
13572 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
13573         LDKChannelManager this_arg_conv;
13574         this_arg_conv.inner = (void*)(this_arg & (~1));
13575         this_arg_conv.is_owned = false;
13576         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13577         *ret = ChannelManager_as_Confirm(&this_arg_conv);
13578         return (uint64_t)ret;
13579 }
13580
13581 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
13582         LDKChannelManager this_arg_conv;
13583         this_arg_conv.inner = (void*)(this_arg & (~1));
13584         this_arg_conv.is_owned = false;
13585         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
13586         return ret_val;
13587 }
13588
13589 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(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         ChannelManager_await_persistable_update(&this_arg_conv);
13594 }
13595
13596 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
13597         LDKChannelManager this_arg_conv;
13598         this_arg_conv.inner = (void*)(this_arg & (~1));
13599         this_arg_conv.is_owned = false;
13600         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13601         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
13602         return (uint64_t)ret;
13603 }
13604
13605 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
13606         LDKChannelManager obj_conv;
13607         obj_conv.inner = (void*)(obj & (~1));
13608         obj_conv.is_owned = false;
13609         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
13610         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13611         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13612         CVec_u8Z_free(ret_var);
13613         return ret_arr;
13614 }
13615
13616 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
13617         LDKChannelManagerReadArgs this_obj_conv;
13618         this_obj_conv.inner = (void*)(this_obj & (~1));
13619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13620         ChannelManagerReadArgs_free(this_obj_conv);
13621 }
13622
13623 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
13624         LDKChannelManagerReadArgs this_ptr_conv;
13625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13626         this_ptr_conv.is_owned = false;
13627         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
13628         return ret_ret;
13629 }
13630
13631 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
13632         LDKChannelManagerReadArgs this_ptr_conv;
13633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13634         this_ptr_conv.is_owned = false;
13635         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
13636         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
13637 }
13638
13639 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
13640         LDKChannelManagerReadArgs this_ptr_conv;
13641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13642         this_ptr_conv.is_owned = false;
13643         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
13644         return ret_ret;
13645 }
13646
13647 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
13648         LDKChannelManagerReadArgs this_ptr_conv;
13649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13650         this_ptr_conv.is_owned = false;
13651         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
13652         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
13653 }
13654
13655 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
13656         LDKChannelManagerReadArgs this_ptr_conv;
13657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13658         this_ptr_conv.is_owned = false;
13659         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
13660         return ret_ret;
13661 }
13662
13663 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
13664         LDKChannelManagerReadArgs this_ptr_conv;
13665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13666         this_ptr_conv.is_owned = false;
13667         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
13668         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
13669 }
13670
13671 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
13672         LDKChannelManagerReadArgs this_ptr_conv;
13673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13674         this_ptr_conv.is_owned = false;
13675         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
13676         return ret_ret;
13677 }
13678
13679 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
13680         LDKChannelManagerReadArgs this_ptr_conv;
13681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13682         this_ptr_conv.is_owned = false;
13683         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
13684         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
13685 }
13686
13687 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
13688         LDKChannelManagerReadArgs this_ptr_conv;
13689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13690         this_ptr_conv.is_owned = false;
13691         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
13692         return ret_ret;
13693 }
13694
13695 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
13696         LDKChannelManagerReadArgs this_ptr_conv;
13697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13698         this_ptr_conv.is_owned = false;
13699         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
13700         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
13701 }
13702
13703 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
13704         LDKChannelManagerReadArgs this_ptr_conv;
13705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13706         this_ptr_conv.is_owned = false;
13707         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
13708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13710         uint64_t ret_ref = (uint64_t)ret_var.inner;
13711         if (ret_var.is_owned) {
13712                 ret_ref |= 1;
13713         }
13714         return ret_ref;
13715 }
13716
13717 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
13718         LDKChannelManagerReadArgs this_ptr_conv;
13719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13720         this_ptr_conv.is_owned = false;
13721         LDKUserConfig val_conv;
13722         val_conv.inner = (void*)(val & (~1));
13723         val_conv.is_owned = (val & 1) || (val == 0);
13724         val_conv = UserConfig_clone(&val_conv);
13725         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
13726 }
13727
13728 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) {
13729         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
13730         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13731         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
13732         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
13733         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13734         LDKUserConfig default_config_conv;
13735         default_config_conv.inner = (void*)(default_config & (~1));
13736         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
13737         default_config_conv = UserConfig_clone(&default_config_conv);
13738         LDKCVec_ChannelMonitorZ channel_monitors_constr;
13739         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
13740         if (channel_monitors_constr.datalen > 0)
13741                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
13742         else
13743                 channel_monitors_constr.data = NULL;
13744         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
13745         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
13746                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
13747                 LDKChannelMonitor channel_monitors_conv_16_conv;
13748                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
13749                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
13750                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
13751         }
13752         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);
13753         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13754         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13755         uint64_t ret_ref = (uint64_t)ret_var.inner;
13756         if (ret_var.is_owned) {
13757                 ret_ref |= 1;
13758         }
13759         return ret_ref;
13760 }
13761
13762 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
13763         LDKu8slice ser_ref;
13764         ser_ref.datalen = *((uint32_t*)ser);
13765         ser_ref.data = (int8_t*)(ser + 4);
13766         LDKChannelManagerReadArgs arg_conv;
13767         arg_conv.inner = (void*)(arg & (~1));
13768         arg_conv.is_owned = (arg & 1) || (arg == 0);
13769         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
13770         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
13771         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
13772         return (uint64_t)ret_conv;
13773 }
13774
13775 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
13776         LDKDecodeError this_obj_conv;
13777         this_obj_conv.inner = (void*)(this_obj & (~1));
13778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13779         DecodeError_free(this_obj_conv);
13780 }
13781
13782 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
13783         LDKDecodeError orig_conv;
13784         orig_conv.inner = (void*)(orig & (~1));
13785         orig_conv.is_owned = false;
13786         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
13787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13789         uint64_t ret_ref = (uint64_t)ret_var.inner;
13790         if (ret_var.is_owned) {
13791                 ret_ref |= 1;
13792         }
13793         return ret_ref;
13794 }
13795
13796 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
13797         LDKInit this_obj_conv;
13798         this_obj_conv.inner = (void*)(this_obj & (~1));
13799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13800         Init_free(this_obj_conv);
13801 }
13802
13803 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
13804         LDKInit this_ptr_conv;
13805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13806         this_ptr_conv.is_owned = false;
13807         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
13808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13810         uint64_t ret_ref = (uint64_t)ret_var.inner;
13811         if (ret_var.is_owned) {
13812                 ret_ref |= 1;
13813         }
13814         return ret_ref;
13815 }
13816
13817 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
13818         LDKInit this_ptr_conv;
13819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13820         this_ptr_conv.is_owned = false;
13821         LDKInitFeatures val_conv;
13822         val_conv.inner = (void*)(val & (~1));
13823         val_conv.is_owned = (val & 1) || (val == 0);
13824         val_conv = InitFeatures_clone(&val_conv);
13825         Init_set_features(&this_ptr_conv, val_conv);
13826 }
13827
13828 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
13829         LDKInitFeatures features_arg_conv;
13830         features_arg_conv.inner = (void*)(features_arg & (~1));
13831         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
13832         features_arg_conv = InitFeatures_clone(&features_arg_conv);
13833         LDKInit ret_var = Init_new(features_arg_conv);
13834         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13835         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13836         uint64_t ret_ref = (uint64_t)ret_var.inner;
13837         if (ret_var.is_owned) {
13838                 ret_ref |= 1;
13839         }
13840         return ret_ref;
13841 }
13842
13843 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
13844         LDKInit orig_conv;
13845         orig_conv.inner = (void*)(orig & (~1));
13846         orig_conv.is_owned = false;
13847         LDKInit ret_var = Init_clone(&orig_conv);
13848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13850         uint64_t ret_ref = (uint64_t)ret_var.inner;
13851         if (ret_var.is_owned) {
13852                 ret_ref |= 1;
13853         }
13854         return ret_ref;
13855 }
13856
13857 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
13858         LDKErrorMessage this_obj_conv;
13859         this_obj_conv.inner = (void*)(this_obj & (~1));
13860         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13861         ErrorMessage_free(this_obj_conv);
13862 }
13863
13864 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
13865         LDKErrorMessage this_ptr_conv;
13866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13867         this_ptr_conv.is_owned = false;
13868         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13869         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
13870         return ret_arr;
13871 }
13872
13873 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13874         LDKErrorMessage this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         LDKThirtyTwoBytes val_ref;
13878         CHECK(*((uint32_t*)val) == 32);
13879         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13880         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
13881 }
13882
13883 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
13884         LDKErrorMessage this_ptr_conv;
13885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13886         this_ptr_conv.is_owned = false;
13887         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
13888         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
13889         return ret_conv;
13890 }
13891
13892 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
13893         LDKErrorMessage this_ptr_conv;
13894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13895         this_ptr_conv.is_owned = false;
13896         LDKStr val_conv = str_ref_to_owned_c(val);
13897         ErrorMessage_set_data(&this_ptr_conv, val_conv);
13898 }
13899
13900 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
13901         LDKThirtyTwoBytes channel_id_arg_ref;
13902         CHECK(*((uint32_t*)channel_id_arg) == 32);
13903         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13904         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
13905         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
13906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13908         uint64_t ret_ref = (uint64_t)ret_var.inner;
13909         if (ret_var.is_owned) {
13910                 ret_ref |= 1;
13911         }
13912         return ret_ref;
13913 }
13914
13915 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
13916         LDKErrorMessage orig_conv;
13917         orig_conv.inner = (void*)(orig & (~1));
13918         orig_conv.is_owned = false;
13919         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
13920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13922         uint64_t ret_ref = (uint64_t)ret_var.inner;
13923         if (ret_var.is_owned) {
13924                 ret_ref |= 1;
13925         }
13926         return ret_ref;
13927 }
13928
13929 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
13930         LDKPing this_obj_conv;
13931         this_obj_conv.inner = (void*)(this_obj & (~1));
13932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13933         Ping_free(this_obj_conv);
13934 }
13935
13936 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
13937         LDKPing this_ptr_conv;
13938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13939         this_ptr_conv.is_owned = false;
13940         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
13941         return ret_val;
13942 }
13943
13944 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
13945         LDKPing this_ptr_conv;
13946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13947         this_ptr_conv.is_owned = false;
13948         Ping_set_ponglen(&this_ptr_conv, val);
13949 }
13950
13951 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
13952         LDKPing this_ptr_conv;
13953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13954         this_ptr_conv.is_owned = false;
13955         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
13956         return ret_val;
13957 }
13958
13959 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
13960         LDKPing this_ptr_conv;
13961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13962         this_ptr_conv.is_owned = false;
13963         Ping_set_byteslen(&this_ptr_conv, val);
13964 }
13965
13966 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
13967         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
13968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13970         uint64_t ret_ref = (uint64_t)ret_var.inner;
13971         if (ret_var.is_owned) {
13972                 ret_ref |= 1;
13973         }
13974         return ret_ref;
13975 }
13976
13977 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
13978         LDKPing orig_conv;
13979         orig_conv.inner = (void*)(orig & (~1));
13980         orig_conv.is_owned = false;
13981         LDKPing ret_var = Ping_clone(&orig_conv);
13982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13984         uint64_t ret_ref = (uint64_t)ret_var.inner;
13985         if (ret_var.is_owned) {
13986                 ret_ref |= 1;
13987         }
13988         return ret_ref;
13989 }
13990
13991 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
13992         LDKPong this_obj_conv;
13993         this_obj_conv.inner = (void*)(this_obj & (~1));
13994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13995         Pong_free(this_obj_conv);
13996 }
13997
13998 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
13999         LDKPong this_ptr_conv;
14000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14001         this_ptr_conv.is_owned = false;
14002         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
14003         return ret_val;
14004 }
14005
14006 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
14007         LDKPong this_ptr_conv;
14008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14009         this_ptr_conv.is_owned = false;
14010         Pong_set_byteslen(&this_ptr_conv, val);
14011 }
14012
14013 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
14014         LDKPong ret_var = Pong_new(byteslen_arg);
14015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14017         uint64_t ret_ref = (uint64_t)ret_var.inner;
14018         if (ret_var.is_owned) {
14019                 ret_ref |= 1;
14020         }
14021         return ret_ref;
14022 }
14023
14024 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
14025         LDKPong orig_conv;
14026         orig_conv.inner = (void*)(orig & (~1));
14027         orig_conv.is_owned = false;
14028         LDKPong ret_var = Pong_clone(&orig_conv);
14029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14031         uint64_t ret_ref = (uint64_t)ret_var.inner;
14032         if (ret_var.is_owned) {
14033                 ret_ref |= 1;
14034         }
14035         return ret_ref;
14036 }
14037
14038 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
14039         LDKOpenChannel this_obj_conv;
14040         this_obj_conv.inner = (void*)(this_obj & (~1));
14041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14042         OpenChannel_free(this_obj_conv);
14043 }
14044
14045 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
14046         LDKOpenChannel this_ptr_conv;
14047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14048         this_ptr_conv.is_owned = false;
14049         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14050         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
14051         return ret_arr;
14052 }
14053
14054 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14055         LDKOpenChannel this_ptr_conv;
14056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14057         this_ptr_conv.is_owned = false;
14058         LDKThirtyTwoBytes val_ref;
14059         CHECK(*((uint32_t*)val) == 32);
14060         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14061         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
14062 }
14063
14064 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
14065         LDKOpenChannel this_ptr_conv;
14066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14067         this_ptr_conv.is_owned = false;
14068         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14069         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14070         return ret_arr;
14071 }
14072
14073 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14074         LDKOpenChannel this_ptr_conv;
14075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14076         this_ptr_conv.is_owned = false;
14077         LDKThirtyTwoBytes val_ref;
14078         CHECK(*((uint32_t*)val) == 32);
14079         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14080         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14081 }
14082
14083 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
14084         LDKOpenChannel this_ptr_conv;
14085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14086         this_ptr_conv.is_owned = false;
14087         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
14088         return ret_val;
14089 }
14090
14091 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
14092         LDKOpenChannel this_ptr_conv;
14093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14094         this_ptr_conv.is_owned = false;
14095         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
14096 }
14097
14098 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
14099         LDKOpenChannel this_ptr_conv;
14100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14101         this_ptr_conv.is_owned = false;
14102         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
14103         return ret_val;
14104 }
14105
14106 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
14107         LDKOpenChannel this_ptr_conv;
14108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14109         this_ptr_conv.is_owned = false;
14110         OpenChannel_set_push_msat(&this_ptr_conv, val);
14111 }
14112
14113 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14114         LDKOpenChannel this_ptr_conv;
14115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14116         this_ptr_conv.is_owned = false;
14117         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
14118         return ret_val;
14119 }
14120
14121 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14122         LDKOpenChannel this_ptr_conv;
14123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14124         this_ptr_conv.is_owned = false;
14125         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14126 }
14127
14128 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14129         LDKOpenChannel this_ptr_conv;
14130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14131         this_ptr_conv.is_owned = false;
14132         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14133         return ret_val;
14134 }
14135
14136 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14137         LDKOpenChannel this_ptr_conv;
14138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14139         this_ptr_conv.is_owned = false;
14140         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14141 }
14142
14143 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14144         LDKOpenChannel this_ptr_conv;
14145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14146         this_ptr_conv.is_owned = false;
14147         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14148         return ret_val;
14149 }
14150
14151 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14152         LDKOpenChannel this_ptr_conv;
14153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14154         this_ptr_conv.is_owned = false;
14155         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14156 }
14157
14158 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14159         LDKOpenChannel this_ptr_conv;
14160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14161         this_ptr_conv.is_owned = false;
14162         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
14163         return ret_val;
14164 }
14165
14166 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14167         LDKOpenChannel this_ptr_conv;
14168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14169         this_ptr_conv.is_owned = false;
14170         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14171 }
14172
14173 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
14174         LDKOpenChannel this_ptr_conv;
14175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14176         this_ptr_conv.is_owned = false;
14177         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
14178         return ret_val;
14179 }
14180
14181 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
14182         LDKOpenChannel this_ptr_conv;
14183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14184         this_ptr_conv.is_owned = false;
14185         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
14186 }
14187
14188 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
14189         LDKOpenChannel this_ptr_conv;
14190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14191         this_ptr_conv.is_owned = false;
14192         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
14193         return ret_val;
14194 }
14195
14196 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14197         LDKOpenChannel this_ptr_conv;
14198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14199         this_ptr_conv.is_owned = false;
14200         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
14201 }
14202
14203 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14204         LDKOpenChannel this_ptr_conv;
14205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14206         this_ptr_conv.is_owned = false;
14207         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
14208         return ret_val;
14209 }
14210
14211 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14212         LDKOpenChannel this_ptr_conv;
14213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14214         this_ptr_conv.is_owned = false;
14215         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14216 }
14217
14218 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
14219         LDKOpenChannel this_ptr_conv;
14220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14221         this_ptr_conv.is_owned = false;
14222         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14223         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14224         return ret_arr;
14225 }
14226
14227 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14228         LDKOpenChannel this_ptr_conv;
14229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14230         this_ptr_conv.is_owned = false;
14231         LDKPublicKey val_ref;
14232         CHECK(*((uint32_t*)val) == 33);
14233         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14234         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14235 }
14236
14237 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
14238         LDKOpenChannel this_ptr_conv;
14239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14240         this_ptr_conv.is_owned = false;
14241         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14242         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14243         return ret_arr;
14244 }
14245
14246 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14247         LDKOpenChannel this_ptr_conv;
14248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14249         this_ptr_conv.is_owned = false;
14250         LDKPublicKey val_ref;
14251         CHECK(*((uint32_t*)val) == 33);
14252         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14253         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14254 }
14255
14256 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
14257         LDKOpenChannel this_ptr_conv;
14258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14259         this_ptr_conv.is_owned = false;
14260         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14261         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14262         return ret_arr;
14263 }
14264
14265 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14266         LDKOpenChannel this_ptr_conv;
14267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14268         this_ptr_conv.is_owned = false;
14269         LDKPublicKey val_ref;
14270         CHECK(*((uint32_t*)val) == 33);
14271         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14272         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
14273 }
14274
14275 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14276         LDKOpenChannel this_ptr_conv;
14277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14278         this_ptr_conv.is_owned = false;
14279         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14280         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14281         return ret_arr;
14282 }
14283
14284 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14285         LDKOpenChannel this_ptr_conv;
14286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14287         this_ptr_conv.is_owned = false;
14288         LDKPublicKey val_ref;
14289         CHECK(*((uint32_t*)val) == 33);
14290         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14291         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14292 }
14293
14294 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
14295         LDKOpenChannel this_ptr_conv;
14296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14297         this_ptr_conv.is_owned = false;
14298         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14299         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14300         return ret_arr;
14301 }
14302
14303 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14304         LDKOpenChannel this_ptr_conv;
14305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14306         this_ptr_conv.is_owned = false;
14307         LDKPublicKey val_ref;
14308         CHECK(*((uint32_t*)val) == 33);
14309         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14310         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14311 }
14312
14313 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14314         LDKOpenChannel this_ptr_conv;
14315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14316         this_ptr_conv.is_owned = false;
14317         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14318         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14319         return ret_arr;
14320 }
14321
14322 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14323         LDKOpenChannel this_ptr_conv;
14324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14325         this_ptr_conv.is_owned = false;
14326         LDKPublicKey val_ref;
14327         CHECK(*((uint32_t*)val) == 33);
14328         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14329         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14330 }
14331
14332 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
14333         LDKOpenChannel this_ptr_conv;
14334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14335         this_ptr_conv.is_owned = false;
14336         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
14337         return ret_val;
14338 }
14339
14340 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
14341         LDKOpenChannel this_ptr_conv;
14342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14343         this_ptr_conv.is_owned = false;
14344         OpenChannel_set_channel_flags(&this_ptr_conv, val);
14345 }
14346
14347 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
14348         LDKOpenChannel orig_conv;
14349         orig_conv.inner = (void*)(orig & (~1));
14350         orig_conv.is_owned = false;
14351         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
14352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14354         uint64_t ret_ref = (uint64_t)ret_var.inner;
14355         if (ret_var.is_owned) {
14356                 ret_ref |= 1;
14357         }
14358         return ret_ref;
14359 }
14360
14361 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
14362         LDKAcceptChannel this_obj_conv;
14363         this_obj_conv.inner = (void*)(this_obj & (~1));
14364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14365         AcceptChannel_free(this_obj_conv);
14366 }
14367
14368 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
14369         LDKAcceptChannel this_ptr_conv;
14370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14371         this_ptr_conv.is_owned = false;
14372         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14373         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
14374         return ret_arr;
14375 }
14376
14377 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14378         LDKAcceptChannel this_ptr_conv;
14379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14380         this_ptr_conv.is_owned = false;
14381         LDKThirtyTwoBytes val_ref;
14382         CHECK(*((uint32_t*)val) == 32);
14383         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14384         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
14385 }
14386
14387 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
14388         LDKAcceptChannel this_ptr_conv;
14389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14390         this_ptr_conv.is_owned = false;
14391         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
14392         return ret_val;
14393 }
14394
14395 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
14396         LDKAcceptChannel this_ptr_conv;
14397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14398         this_ptr_conv.is_owned = false;
14399         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
14400 }
14401
14402 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
14403         LDKAcceptChannel this_ptr_conv;
14404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14405         this_ptr_conv.is_owned = false;
14406         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
14407         return ret_val;
14408 }
14409
14410 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
14411         LDKAcceptChannel this_ptr_conv;
14412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14413         this_ptr_conv.is_owned = false;
14414         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
14415 }
14416
14417 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
14418         LDKAcceptChannel this_ptr_conv;
14419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14420         this_ptr_conv.is_owned = false;
14421         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
14422         return ret_val;
14423 }
14424
14425 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
14426         LDKAcceptChannel this_ptr_conv;
14427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14428         this_ptr_conv.is_owned = false;
14429         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
14430 }
14431
14432 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
14433         LDKAcceptChannel this_ptr_conv;
14434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14435         this_ptr_conv.is_owned = false;
14436         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
14437         return ret_val;
14438 }
14439
14440 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14441         LDKAcceptChannel this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
14445 }
14446
14447 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
14448         LDKAcceptChannel this_ptr_conv;
14449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14450         this_ptr_conv.is_owned = false;
14451         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
14452         return ret_val;
14453 }
14454
14455 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
14456         LDKAcceptChannel this_ptr_conv;
14457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14458         this_ptr_conv.is_owned = false;
14459         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
14460 }
14461
14462 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
14463         LDKAcceptChannel this_ptr_conv;
14464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14465         this_ptr_conv.is_owned = false;
14466         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
14467         return ret_val;
14468 }
14469
14470 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14471         LDKAcceptChannel this_ptr_conv;
14472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14473         this_ptr_conv.is_owned = false;
14474         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
14475 }
14476
14477 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
14478         LDKAcceptChannel this_ptr_conv;
14479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14480         this_ptr_conv.is_owned = false;
14481         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
14482         return ret_val;
14483 }
14484
14485 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
14486         LDKAcceptChannel this_ptr_conv;
14487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14488         this_ptr_conv.is_owned = false;
14489         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
14490 }
14491
14492 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
14493         LDKAcceptChannel this_ptr_conv;
14494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14495         this_ptr_conv.is_owned = false;
14496         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14497         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
14498         return ret_arr;
14499 }
14500
14501 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
14502         LDKAcceptChannel this_ptr_conv;
14503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14504         this_ptr_conv.is_owned = false;
14505         LDKPublicKey val_ref;
14506         CHECK(*((uint32_t*)val) == 33);
14507         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14508         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
14509 }
14510
14511 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
14512         LDKAcceptChannel this_ptr_conv;
14513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14514         this_ptr_conv.is_owned = false;
14515         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14516         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
14517         return ret_arr;
14518 }
14519
14520 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
14521         LDKAcceptChannel this_ptr_conv;
14522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14523         this_ptr_conv.is_owned = false;
14524         LDKPublicKey val_ref;
14525         CHECK(*((uint32_t*)val) == 33);
14526         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14527         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
14528 }
14529
14530 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
14531         LDKAcceptChannel this_ptr_conv;
14532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14533         this_ptr_conv.is_owned = false;
14534         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14535         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
14536         return ret_arr;
14537 }
14538
14539 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
14540         LDKAcceptChannel this_ptr_conv;
14541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14542         this_ptr_conv.is_owned = false;
14543         LDKPublicKey val_ref;
14544         CHECK(*((uint32_t*)val) == 33);
14545         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14546         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
14547 }
14548
14549 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
14550         LDKAcceptChannel this_ptr_conv;
14551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14552         this_ptr_conv.is_owned = false;
14553         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14554         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
14555         return ret_arr;
14556 }
14557
14558 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
14559         LDKAcceptChannel this_ptr_conv;
14560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14561         this_ptr_conv.is_owned = false;
14562         LDKPublicKey val_ref;
14563         CHECK(*((uint32_t*)val) == 33);
14564         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14565         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
14566 }
14567
14568 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
14569         LDKAcceptChannel this_ptr_conv;
14570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14571         this_ptr_conv.is_owned = false;
14572         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14573         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
14574         return ret_arr;
14575 }
14576
14577 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
14578         LDKAcceptChannel this_ptr_conv;
14579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14580         this_ptr_conv.is_owned = false;
14581         LDKPublicKey val_ref;
14582         CHECK(*((uint32_t*)val) == 33);
14583         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14584         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
14585 }
14586
14587 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
14588         LDKAcceptChannel this_ptr_conv;
14589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14590         this_ptr_conv.is_owned = false;
14591         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14592         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14593         return ret_arr;
14594 }
14595
14596 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14597         LDKAcceptChannel this_ptr_conv;
14598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14599         this_ptr_conv.is_owned = false;
14600         LDKPublicKey val_ref;
14601         CHECK(*((uint32_t*)val) == 33);
14602         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14603         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
14604 }
14605
14606 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
14607         LDKAcceptChannel orig_conv;
14608         orig_conv.inner = (void*)(orig & (~1));
14609         orig_conv.is_owned = false;
14610         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
14611         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14612         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14613         uint64_t ret_ref = (uint64_t)ret_var.inner;
14614         if (ret_var.is_owned) {
14615                 ret_ref |= 1;
14616         }
14617         return ret_ref;
14618 }
14619
14620 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
14621         LDKFundingCreated this_obj_conv;
14622         this_obj_conv.inner = (void*)(this_obj & (~1));
14623         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14624         FundingCreated_free(this_obj_conv);
14625 }
14626
14627 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
14628         LDKFundingCreated this_ptr_conv;
14629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14630         this_ptr_conv.is_owned = false;
14631         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14632         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
14633         return ret_arr;
14634 }
14635
14636 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
14637         LDKFundingCreated this_ptr_conv;
14638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14639         this_ptr_conv.is_owned = false;
14640         LDKThirtyTwoBytes val_ref;
14641         CHECK(*((uint32_t*)val) == 32);
14642         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14643         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
14644 }
14645
14646 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
14647         LDKFundingCreated this_ptr_conv;
14648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14649         this_ptr_conv.is_owned = false;
14650         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14651         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
14652         return ret_arr;
14653 }
14654
14655 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
14656         LDKFundingCreated this_ptr_conv;
14657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14658         this_ptr_conv.is_owned = false;
14659         LDKThirtyTwoBytes val_ref;
14660         CHECK(*((uint32_t*)val) == 32);
14661         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14662         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
14663 }
14664
14665 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
14666         LDKFundingCreated this_ptr_conv;
14667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14668         this_ptr_conv.is_owned = false;
14669         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
14670         return ret_val;
14671 }
14672
14673 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
14674         LDKFundingCreated this_ptr_conv;
14675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14676         this_ptr_conv.is_owned = false;
14677         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
14678 }
14679
14680 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
14681         LDKFundingCreated this_ptr_conv;
14682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14683         this_ptr_conv.is_owned = false;
14684         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14685         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
14686         return ret_arr;
14687 }
14688
14689 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
14690         LDKFundingCreated this_ptr_conv;
14691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14692         this_ptr_conv.is_owned = false;
14693         LDKSignature val_ref;
14694         CHECK(*((uint32_t*)val) == 64);
14695         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14696         FundingCreated_set_signature(&this_ptr_conv, val_ref);
14697 }
14698
14699 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) {
14700         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
14701         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
14702         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
14703         LDKThirtyTwoBytes funding_txid_arg_ref;
14704         CHECK(*((uint32_t*)funding_txid_arg) == 32);
14705         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
14706         LDKSignature signature_arg_ref;
14707         CHECK(*((uint32_t*)signature_arg) == 64);
14708         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14709         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
14710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14712         uint64_t ret_ref = (uint64_t)ret_var.inner;
14713         if (ret_var.is_owned) {
14714                 ret_ref |= 1;
14715         }
14716         return ret_ref;
14717 }
14718
14719 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
14720         LDKFundingCreated orig_conv;
14721         orig_conv.inner = (void*)(orig & (~1));
14722         orig_conv.is_owned = false;
14723         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
14724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14726         uint64_t ret_ref = (uint64_t)ret_var.inner;
14727         if (ret_var.is_owned) {
14728                 ret_ref |= 1;
14729         }
14730         return ret_ref;
14731 }
14732
14733 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
14734         LDKFundingSigned this_obj_conv;
14735         this_obj_conv.inner = (void*)(this_obj & (~1));
14736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14737         FundingSigned_free(this_obj_conv);
14738 }
14739
14740 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
14741         LDKFundingSigned this_ptr_conv;
14742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14743         this_ptr_conv.is_owned = false;
14744         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14745         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
14746         return ret_arr;
14747 }
14748
14749 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14750         LDKFundingSigned this_ptr_conv;
14751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14752         this_ptr_conv.is_owned = false;
14753         LDKThirtyTwoBytes val_ref;
14754         CHECK(*((uint32_t*)val) == 32);
14755         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14756         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
14757 }
14758
14759 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
14760         LDKFundingSigned this_ptr_conv;
14761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14762         this_ptr_conv.is_owned = false;
14763         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14764         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
14765         return ret_arr;
14766 }
14767
14768 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
14769         LDKFundingSigned this_ptr_conv;
14770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14771         this_ptr_conv.is_owned = false;
14772         LDKSignature val_ref;
14773         CHECK(*((uint32_t*)val) == 64);
14774         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14775         FundingSigned_set_signature(&this_ptr_conv, val_ref);
14776 }
14777
14778 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
14779         LDKThirtyTwoBytes channel_id_arg_ref;
14780         CHECK(*((uint32_t*)channel_id_arg) == 32);
14781         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14782         LDKSignature signature_arg_ref;
14783         CHECK(*((uint32_t*)signature_arg) == 64);
14784         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14785         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
14786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14788         uint64_t ret_ref = (uint64_t)ret_var.inner;
14789         if (ret_var.is_owned) {
14790                 ret_ref |= 1;
14791         }
14792         return ret_ref;
14793 }
14794
14795 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
14796         LDKFundingSigned orig_conv;
14797         orig_conv.inner = (void*)(orig & (~1));
14798         orig_conv.is_owned = false;
14799         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
14800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14802         uint64_t ret_ref = (uint64_t)ret_var.inner;
14803         if (ret_var.is_owned) {
14804                 ret_ref |= 1;
14805         }
14806         return ret_ref;
14807 }
14808
14809 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
14810         LDKFundingLocked this_obj_conv;
14811         this_obj_conv.inner = (void*)(this_obj & (~1));
14812         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14813         FundingLocked_free(this_obj_conv);
14814 }
14815
14816 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
14817         LDKFundingLocked this_ptr_conv;
14818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14819         this_ptr_conv.is_owned = false;
14820         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14821         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
14822         return ret_arr;
14823 }
14824
14825 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14826         LDKFundingLocked this_ptr_conv;
14827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14828         this_ptr_conv.is_owned = false;
14829         LDKThirtyTwoBytes val_ref;
14830         CHECK(*((uint32_t*)val) == 32);
14831         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14832         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
14833 }
14834
14835 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
14836         LDKFundingLocked this_ptr_conv;
14837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14838         this_ptr_conv.is_owned = false;
14839         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14840         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14841         return ret_arr;
14842 }
14843
14844 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14845         LDKFundingLocked this_ptr_conv;
14846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14847         this_ptr_conv.is_owned = false;
14848         LDKPublicKey val_ref;
14849         CHECK(*((uint32_t*)val) == 33);
14850         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14851         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
14852 }
14853
14854 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
14855         LDKThirtyTwoBytes channel_id_arg_ref;
14856         CHECK(*((uint32_t*)channel_id_arg) == 32);
14857         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14858         LDKPublicKey next_per_commitment_point_arg_ref;
14859         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
14860         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
14861         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
14862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14864         uint64_t ret_ref = (uint64_t)ret_var.inner;
14865         if (ret_var.is_owned) {
14866                 ret_ref |= 1;
14867         }
14868         return ret_ref;
14869 }
14870
14871 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
14872         LDKFundingLocked orig_conv;
14873         orig_conv.inner = (void*)(orig & (~1));
14874         orig_conv.is_owned = false;
14875         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
14876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14878         uint64_t ret_ref = (uint64_t)ret_var.inner;
14879         if (ret_var.is_owned) {
14880                 ret_ref |= 1;
14881         }
14882         return ret_ref;
14883 }
14884
14885 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
14886         LDKShutdown this_obj_conv;
14887         this_obj_conv.inner = (void*)(this_obj & (~1));
14888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14889         Shutdown_free(this_obj_conv);
14890 }
14891
14892 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
14893         LDKShutdown this_ptr_conv;
14894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14895         this_ptr_conv.is_owned = false;
14896         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14897         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
14898         return ret_arr;
14899 }
14900
14901 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14902         LDKShutdown this_ptr_conv;
14903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14904         this_ptr_conv.is_owned = false;
14905         LDKThirtyTwoBytes val_ref;
14906         CHECK(*((uint32_t*)val) == 32);
14907         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14908         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
14909 }
14910
14911 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
14912         LDKShutdown this_ptr_conv;
14913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14914         this_ptr_conv.is_owned = false;
14915         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
14916         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14917         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14918         return ret_arr;
14919 }
14920
14921 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
14922         LDKShutdown this_ptr_conv;
14923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14924         this_ptr_conv.is_owned = false;
14925         LDKCVec_u8Z val_ref;
14926         val_ref.datalen = *((uint32_t*)val);
14927         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14928         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14929         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
14930 }
14931
14932 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
14933         LDKThirtyTwoBytes channel_id_arg_ref;
14934         CHECK(*((uint32_t*)channel_id_arg) == 32);
14935         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
14936         LDKCVec_u8Z scriptpubkey_arg_ref;
14937         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
14938         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14939         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
14940         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
14941         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14942         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14943         uint64_t ret_ref = (uint64_t)ret_var.inner;
14944         if (ret_var.is_owned) {
14945                 ret_ref |= 1;
14946         }
14947         return ret_ref;
14948 }
14949
14950 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
14951         LDKShutdown orig_conv;
14952         orig_conv.inner = (void*)(orig & (~1));
14953         orig_conv.is_owned = false;
14954         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
14955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14957         uint64_t ret_ref = (uint64_t)ret_var.inner;
14958         if (ret_var.is_owned) {
14959                 ret_ref |= 1;
14960         }
14961         return ret_ref;
14962 }
14963
14964 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
14965         LDKClosingSigned this_obj_conv;
14966         this_obj_conv.inner = (void*)(this_obj & (~1));
14967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14968         ClosingSigned_free(this_obj_conv);
14969 }
14970
14971 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
14972         LDKClosingSigned this_ptr_conv;
14973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14974         this_ptr_conv.is_owned = false;
14975         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14976         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
14977         return ret_arr;
14978 }
14979
14980 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
14981         LDKClosingSigned this_ptr_conv;
14982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14983         this_ptr_conv.is_owned = false;
14984         LDKThirtyTwoBytes val_ref;
14985         CHECK(*((uint32_t*)val) == 32);
14986         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14987         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
14988 }
14989
14990 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
14991         LDKClosingSigned this_ptr_conv;
14992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14993         this_ptr_conv.is_owned = false;
14994         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
14995         return ret_val;
14996 }
14997
14998 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
14999         LDKClosingSigned this_ptr_conv;
15000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15001         this_ptr_conv.is_owned = false;
15002         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
15003 }
15004
15005 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
15006         LDKClosingSigned this_ptr_conv;
15007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15008         this_ptr_conv.is_owned = false;
15009         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15010         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
15011         return ret_arr;
15012 }
15013
15014 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15015         LDKClosingSigned this_ptr_conv;
15016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15017         this_ptr_conv.is_owned = false;
15018         LDKSignature val_ref;
15019         CHECK(*((uint32_t*)val) == 64);
15020         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15021         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
15022 }
15023
15024 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
15025         LDKThirtyTwoBytes channel_id_arg_ref;
15026         CHECK(*((uint32_t*)channel_id_arg) == 32);
15027         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15028         LDKSignature signature_arg_ref;
15029         CHECK(*((uint32_t*)signature_arg) == 64);
15030         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15031         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
15032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15034         uint64_t ret_ref = (uint64_t)ret_var.inner;
15035         if (ret_var.is_owned) {
15036                 ret_ref |= 1;
15037         }
15038         return ret_ref;
15039 }
15040
15041 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
15042         LDKClosingSigned orig_conv;
15043         orig_conv.inner = (void*)(orig & (~1));
15044         orig_conv.is_owned = false;
15045         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
15046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15048         uint64_t ret_ref = (uint64_t)ret_var.inner;
15049         if (ret_var.is_owned) {
15050                 ret_ref |= 1;
15051         }
15052         return ret_ref;
15053 }
15054
15055 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
15056         LDKUpdateAddHTLC this_obj_conv;
15057         this_obj_conv.inner = (void*)(this_obj & (~1));
15058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15059         UpdateAddHTLC_free(this_obj_conv);
15060 }
15061
15062 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
15063         LDKUpdateAddHTLC this_ptr_conv;
15064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15065         this_ptr_conv.is_owned = false;
15066         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15067         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
15068         return ret_arr;
15069 }
15070
15071 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15072         LDKUpdateAddHTLC this_ptr_conv;
15073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15074         this_ptr_conv.is_owned = false;
15075         LDKThirtyTwoBytes val_ref;
15076         CHECK(*((uint32_t*)val) == 32);
15077         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15078         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
15079 }
15080
15081 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
15082         LDKUpdateAddHTLC this_ptr_conv;
15083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15084         this_ptr_conv.is_owned = false;
15085         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
15086         return ret_val;
15087 }
15088
15089 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15090         LDKUpdateAddHTLC this_ptr_conv;
15091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15092         this_ptr_conv.is_owned = false;
15093         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
15094 }
15095
15096 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
15097         LDKUpdateAddHTLC this_ptr_conv;
15098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15099         this_ptr_conv.is_owned = false;
15100         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
15101         return ret_val;
15102 }
15103
15104 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
15105         LDKUpdateAddHTLC this_ptr_conv;
15106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15107         this_ptr_conv.is_owned = false;
15108         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
15109 }
15110
15111 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
15112         LDKUpdateAddHTLC this_ptr_conv;
15113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15114         this_ptr_conv.is_owned = false;
15115         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15116         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
15117         return ret_arr;
15118 }
15119
15120 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
15121         LDKUpdateAddHTLC this_ptr_conv;
15122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15123         this_ptr_conv.is_owned = false;
15124         LDKThirtyTwoBytes val_ref;
15125         CHECK(*((uint32_t*)val) == 32);
15126         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15127         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
15128 }
15129
15130 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
15131         LDKUpdateAddHTLC this_ptr_conv;
15132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15133         this_ptr_conv.is_owned = false;
15134         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
15135         return ret_val;
15136 }
15137
15138 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
15139         LDKUpdateAddHTLC this_ptr_conv;
15140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15141         this_ptr_conv.is_owned = false;
15142         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
15143 }
15144
15145 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
15146         LDKUpdateAddHTLC orig_conv;
15147         orig_conv.inner = (void*)(orig & (~1));
15148         orig_conv.is_owned = false;
15149         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
15150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15152         uint64_t ret_ref = (uint64_t)ret_var.inner;
15153         if (ret_var.is_owned) {
15154                 ret_ref |= 1;
15155         }
15156         return ret_ref;
15157 }
15158
15159 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
15160         LDKUpdateFulfillHTLC this_obj_conv;
15161         this_obj_conv.inner = (void*)(this_obj & (~1));
15162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15163         UpdateFulfillHTLC_free(this_obj_conv);
15164 }
15165
15166 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
15167         LDKUpdateFulfillHTLC this_ptr_conv;
15168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15169         this_ptr_conv.is_owned = false;
15170         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15171         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
15172         return ret_arr;
15173 }
15174
15175 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15176         LDKUpdateFulfillHTLC this_ptr_conv;
15177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15178         this_ptr_conv.is_owned = false;
15179         LDKThirtyTwoBytes val_ref;
15180         CHECK(*((uint32_t*)val) == 32);
15181         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15182         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
15183 }
15184
15185 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
15186         LDKUpdateFulfillHTLC this_ptr_conv;
15187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15188         this_ptr_conv.is_owned = false;
15189         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
15190         return ret_val;
15191 }
15192
15193 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15194         LDKUpdateFulfillHTLC this_ptr_conv;
15195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15196         this_ptr_conv.is_owned = false;
15197         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
15198 }
15199
15200 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
15201         LDKUpdateFulfillHTLC this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15205         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
15206         return ret_arr;
15207 }
15208
15209 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
15210         LDKUpdateFulfillHTLC this_ptr_conv;
15211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15212         this_ptr_conv.is_owned = false;
15213         LDKThirtyTwoBytes val_ref;
15214         CHECK(*((uint32_t*)val) == 32);
15215         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15216         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
15217 }
15218
15219 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
15220         LDKThirtyTwoBytes channel_id_arg_ref;
15221         CHECK(*((uint32_t*)channel_id_arg) == 32);
15222         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15223         LDKThirtyTwoBytes payment_preimage_arg_ref;
15224         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
15225         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
15226         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
15227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15229         uint64_t ret_ref = (uint64_t)ret_var.inner;
15230         if (ret_var.is_owned) {
15231                 ret_ref |= 1;
15232         }
15233         return ret_ref;
15234 }
15235
15236 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
15237         LDKUpdateFulfillHTLC orig_conv;
15238         orig_conv.inner = (void*)(orig & (~1));
15239         orig_conv.is_owned = false;
15240         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
15241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15243         uint64_t ret_ref = (uint64_t)ret_var.inner;
15244         if (ret_var.is_owned) {
15245                 ret_ref |= 1;
15246         }
15247         return ret_ref;
15248 }
15249
15250 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
15251         LDKUpdateFailHTLC this_obj_conv;
15252         this_obj_conv.inner = (void*)(this_obj & (~1));
15253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15254         UpdateFailHTLC_free(this_obj_conv);
15255 }
15256
15257 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
15258         LDKUpdateFailHTLC 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(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15262         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
15263         return ret_arr;
15264 }
15265
15266 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15267         LDKUpdateFailHTLC this_ptr_conv;
15268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15269         this_ptr_conv.is_owned = false;
15270         LDKThirtyTwoBytes val_ref;
15271         CHECK(*((uint32_t*)val) == 32);
15272         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15273         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
15274 }
15275
15276 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
15277         LDKUpdateFailHTLC this_ptr_conv;
15278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15279         this_ptr_conv.is_owned = false;
15280         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
15281         return ret_val;
15282 }
15283
15284 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15285         LDKUpdateFailHTLC this_ptr_conv;
15286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15287         this_ptr_conv.is_owned = false;
15288         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
15289 }
15290
15291 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
15292         LDKUpdateFailHTLC orig_conv;
15293         orig_conv.inner = (void*)(orig & (~1));
15294         orig_conv.is_owned = false;
15295         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
15296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15298         uint64_t ret_ref = (uint64_t)ret_var.inner;
15299         if (ret_var.is_owned) {
15300                 ret_ref |= 1;
15301         }
15302         return ret_ref;
15303 }
15304
15305 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
15306         LDKUpdateFailMalformedHTLC this_obj_conv;
15307         this_obj_conv.inner = (void*)(this_obj & (~1));
15308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15309         UpdateFailMalformedHTLC_free(this_obj_conv);
15310 }
15311
15312 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
15313         LDKUpdateFailMalformedHTLC this_ptr_conv;
15314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15315         this_ptr_conv.is_owned = false;
15316         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15317         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
15318         return ret_arr;
15319 }
15320
15321 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15322         LDKUpdateFailMalformedHTLC this_ptr_conv;
15323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15324         this_ptr_conv.is_owned = false;
15325         LDKThirtyTwoBytes val_ref;
15326         CHECK(*((uint32_t*)val) == 32);
15327         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15328         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
15329 }
15330
15331 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
15332         LDKUpdateFailMalformedHTLC this_ptr_conv;
15333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15334         this_ptr_conv.is_owned = false;
15335         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
15336         return ret_val;
15337 }
15338
15339 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
15340         LDKUpdateFailMalformedHTLC this_ptr_conv;
15341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15342         this_ptr_conv.is_owned = false;
15343         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
15344 }
15345
15346 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
15347         LDKUpdateFailMalformedHTLC this_ptr_conv;
15348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15349         this_ptr_conv.is_owned = false;
15350         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
15351         return ret_val;
15352 }
15353
15354 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
15355         LDKUpdateFailMalformedHTLC this_ptr_conv;
15356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15357         this_ptr_conv.is_owned = false;
15358         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
15359 }
15360
15361 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
15362         LDKUpdateFailMalformedHTLC orig_conv;
15363         orig_conv.inner = (void*)(orig & (~1));
15364         orig_conv.is_owned = false;
15365         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
15366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15368         uint64_t ret_ref = (uint64_t)ret_var.inner;
15369         if (ret_var.is_owned) {
15370                 ret_ref |= 1;
15371         }
15372         return ret_ref;
15373 }
15374
15375 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
15376         LDKCommitmentSigned this_obj_conv;
15377         this_obj_conv.inner = (void*)(this_obj & (~1));
15378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15379         CommitmentSigned_free(this_obj_conv);
15380 }
15381
15382 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
15383         LDKCommitmentSigned this_ptr_conv;
15384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15385         this_ptr_conv.is_owned = false;
15386         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15387         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
15388         return ret_arr;
15389 }
15390
15391 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15392         LDKCommitmentSigned this_ptr_conv;
15393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15394         this_ptr_conv.is_owned = false;
15395         LDKThirtyTwoBytes val_ref;
15396         CHECK(*((uint32_t*)val) == 32);
15397         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15398         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
15399 }
15400
15401 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
15402         LDKCommitmentSigned this_ptr_conv;
15403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404         this_ptr_conv.is_owned = false;
15405         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15406         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
15407         return ret_arr;
15408 }
15409
15410 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
15411         LDKCommitmentSigned this_ptr_conv;
15412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15413         this_ptr_conv.is_owned = false;
15414         LDKSignature val_ref;
15415         CHECK(*((uint32_t*)val) == 64);
15416         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15417         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
15418 }
15419
15420 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
15421         LDKCommitmentSigned this_ptr_conv;
15422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15423         this_ptr_conv.is_owned = false;
15424         LDKCVec_SignatureZ val_constr;
15425         val_constr.datalen = *((uint32_t*)val);
15426         if (val_constr.datalen > 0)
15427                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15428         else
15429                 val_constr.data = NULL;
15430         int8_tArray* val_vals = (int8_tArray*)(val + 4);
15431         for (size_t m = 0; m < val_constr.datalen; m++) {
15432                 int8_tArray val_conv_12 = val_vals[m];
15433                 LDKSignature val_conv_12_ref;
15434                 CHECK(*((uint32_t*)val_conv_12) == 64);
15435                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
15436                 val_constr.data[m] = val_conv_12_ref;
15437         }
15438         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
15439 }
15440
15441 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
15442         LDKThirtyTwoBytes channel_id_arg_ref;
15443         CHECK(*((uint32_t*)channel_id_arg) == 32);
15444         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15445         LDKSignature signature_arg_ref;
15446         CHECK(*((uint32_t*)signature_arg) == 64);
15447         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
15448         LDKCVec_SignatureZ htlc_signatures_arg_constr;
15449         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
15450         if (htlc_signatures_arg_constr.datalen > 0)
15451                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15452         else
15453                 htlc_signatures_arg_constr.data = NULL;
15454         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
15455         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
15456                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
15457                 LDKSignature htlc_signatures_arg_conv_12_ref;
15458                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
15459                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
15460                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
15461         }
15462         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
15463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15465         uint64_t ret_ref = (uint64_t)ret_var.inner;
15466         if (ret_var.is_owned) {
15467                 ret_ref |= 1;
15468         }
15469         return ret_ref;
15470 }
15471
15472 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
15473         LDKCommitmentSigned orig_conv;
15474         orig_conv.inner = (void*)(orig & (~1));
15475         orig_conv.is_owned = false;
15476         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
15477         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15478         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15479         uint64_t ret_ref = (uint64_t)ret_var.inner;
15480         if (ret_var.is_owned) {
15481                 ret_ref |= 1;
15482         }
15483         return ret_ref;
15484 }
15485
15486 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
15487         LDKRevokeAndACK this_obj_conv;
15488         this_obj_conv.inner = (void*)(this_obj & (~1));
15489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15490         RevokeAndACK_free(this_obj_conv);
15491 }
15492
15493 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
15494         LDKRevokeAndACK this_ptr_conv;
15495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15496         this_ptr_conv.is_owned = false;
15497         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15498         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
15499         return ret_arr;
15500 }
15501
15502 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15503         LDKRevokeAndACK this_ptr_conv;
15504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15505         this_ptr_conv.is_owned = false;
15506         LDKThirtyTwoBytes val_ref;
15507         CHECK(*((uint32_t*)val) == 32);
15508         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15509         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
15510 }
15511
15512 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
15513         LDKRevokeAndACK this_ptr_conv;
15514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15515         this_ptr_conv.is_owned = false;
15516         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15517         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
15518         return ret_arr;
15519 }
15520
15521 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15522         LDKRevokeAndACK this_ptr_conv;
15523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15524         this_ptr_conv.is_owned = false;
15525         LDKThirtyTwoBytes val_ref;
15526         CHECK(*((uint32_t*)val) == 32);
15527         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15528         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
15529 }
15530
15531 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
15532         LDKRevokeAndACK this_ptr_conv;
15533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15534         this_ptr_conv.is_owned = false;
15535         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15536         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15537         return ret_arr;
15538 }
15539
15540 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15541         LDKRevokeAndACK this_ptr_conv;
15542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15543         this_ptr_conv.is_owned = false;
15544         LDKPublicKey val_ref;
15545         CHECK(*((uint32_t*)val) == 33);
15546         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15547         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
15548 }
15549
15550 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) {
15551         LDKThirtyTwoBytes channel_id_arg_ref;
15552         CHECK(*((uint32_t*)channel_id_arg) == 32);
15553         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15554         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
15555         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
15556         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
15557         LDKPublicKey next_per_commitment_point_arg_ref;
15558         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
15559         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
15560         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
15561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15563         uint64_t ret_ref = (uint64_t)ret_var.inner;
15564         if (ret_var.is_owned) {
15565                 ret_ref |= 1;
15566         }
15567         return ret_ref;
15568 }
15569
15570 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
15571         LDKRevokeAndACK orig_conv;
15572         orig_conv.inner = (void*)(orig & (~1));
15573         orig_conv.is_owned = false;
15574         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
15575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15577         uint64_t ret_ref = (uint64_t)ret_var.inner;
15578         if (ret_var.is_owned) {
15579                 ret_ref |= 1;
15580         }
15581         return ret_ref;
15582 }
15583
15584 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
15585         LDKUpdateFee this_obj_conv;
15586         this_obj_conv.inner = (void*)(this_obj & (~1));
15587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15588         UpdateFee_free(this_obj_conv);
15589 }
15590
15591 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
15592         LDKUpdateFee this_ptr_conv;
15593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15594         this_ptr_conv.is_owned = false;
15595         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15596         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
15597         return ret_arr;
15598 }
15599
15600 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15601         LDKUpdateFee this_ptr_conv;
15602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15603         this_ptr_conv.is_owned = false;
15604         LDKThirtyTwoBytes val_ref;
15605         CHECK(*((uint32_t*)val) == 32);
15606         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15607         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
15608 }
15609
15610 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
15611         LDKUpdateFee this_ptr_conv;
15612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15613         this_ptr_conv.is_owned = false;
15614         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
15615         return ret_val;
15616 }
15617
15618 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
15619         LDKUpdateFee this_ptr_conv;
15620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15621         this_ptr_conv.is_owned = false;
15622         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
15623 }
15624
15625 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
15626         LDKThirtyTwoBytes channel_id_arg_ref;
15627         CHECK(*((uint32_t*)channel_id_arg) == 32);
15628         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15629         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
15630         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15631         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15632         uint64_t ret_ref = (uint64_t)ret_var.inner;
15633         if (ret_var.is_owned) {
15634                 ret_ref |= 1;
15635         }
15636         return ret_ref;
15637 }
15638
15639 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
15640         LDKUpdateFee orig_conv;
15641         orig_conv.inner = (void*)(orig & (~1));
15642         orig_conv.is_owned = false;
15643         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
15644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15646         uint64_t ret_ref = (uint64_t)ret_var.inner;
15647         if (ret_var.is_owned) {
15648                 ret_ref |= 1;
15649         }
15650         return ret_ref;
15651 }
15652
15653 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
15654         LDKDataLossProtect this_obj_conv;
15655         this_obj_conv.inner = (void*)(this_obj & (~1));
15656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15657         DataLossProtect_free(this_obj_conv);
15658 }
15659
15660 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
15661         LDKDataLossProtect this_ptr_conv;
15662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15663         this_ptr_conv.is_owned = false;
15664         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15665         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
15666         return ret_arr;
15667 }
15668
15669 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
15670         LDKDataLossProtect this_ptr_conv;
15671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15672         this_ptr_conv.is_owned = false;
15673         LDKThirtyTwoBytes val_ref;
15674         CHECK(*((uint32_t*)val) == 32);
15675         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15676         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
15677 }
15678
15679 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
15680         LDKDataLossProtect this_ptr_conv;
15681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15682         this_ptr_conv.is_owned = false;
15683         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15684         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
15685         return ret_arr;
15686 }
15687
15688 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
15689         LDKDataLossProtect this_ptr_conv;
15690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15691         this_ptr_conv.is_owned = false;
15692         LDKPublicKey val_ref;
15693         CHECK(*((uint32_t*)val) == 33);
15694         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15695         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
15696 }
15697
15698 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
15699         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
15700         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
15701         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
15702         LDKPublicKey my_current_per_commitment_point_arg_ref;
15703         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
15704         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
15705         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
15706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15708         uint64_t ret_ref = (uint64_t)ret_var.inner;
15709         if (ret_var.is_owned) {
15710                 ret_ref |= 1;
15711         }
15712         return ret_ref;
15713 }
15714
15715 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
15716         LDKDataLossProtect orig_conv;
15717         orig_conv.inner = (void*)(orig & (~1));
15718         orig_conv.is_owned = false;
15719         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
15720         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15721         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15722         uint64_t ret_ref = (uint64_t)ret_var.inner;
15723         if (ret_var.is_owned) {
15724                 ret_ref |= 1;
15725         }
15726         return ret_ref;
15727 }
15728
15729 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
15730         LDKChannelReestablish this_obj_conv;
15731         this_obj_conv.inner = (void*)(this_obj & (~1));
15732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15733         ChannelReestablish_free(this_obj_conv);
15734 }
15735
15736 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
15737         LDKChannelReestablish this_ptr_conv;
15738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15739         this_ptr_conv.is_owned = false;
15740         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15741         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
15742         return ret_arr;
15743 }
15744
15745 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15746         LDKChannelReestablish this_ptr_conv;
15747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15748         this_ptr_conv.is_owned = false;
15749         LDKThirtyTwoBytes val_ref;
15750         CHECK(*((uint32_t*)val) == 32);
15751         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15752         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
15753 }
15754
15755 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
15756         LDKChannelReestablish this_ptr_conv;
15757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15758         this_ptr_conv.is_owned = false;
15759         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
15760         return ret_val;
15761 }
15762
15763 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
15764         LDKChannelReestablish this_ptr_conv;
15765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15766         this_ptr_conv.is_owned = false;
15767         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
15768 }
15769
15770 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
15771         LDKChannelReestablish this_ptr_conv;
15772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15773         this_ptr_conv.is_owned = false;
15774         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
15775         return ret_val;
15776 }
15777
15778 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
15779         LDKChannelReestablish this_ptr_conv;
15780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15781         this_ptr_conv.is_owned = false;
15782         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
15783 }
15784
15785 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
15786         LDKChannelReestablish orig_conv;
15787         orig_conv.inner = (void*)(orig & (~1));
15788         orig_conv.is_owned = false;
15789         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
15790         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15791         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15792         uint64_t ret_ref = (uint64_t)ret_var.inner;
15793         if (ret_var.is_owned) {
15794                 ret_ref |= 1;
15795         }
15796         return ret_ref;
15797 }
15798
15799 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
15800         LDKAnnouncementSignatures this_obj_conv;
15801         this_obj_conv.inner = (void*)(this_obj & (~1));
15802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15803         AnnouncementSignatures_free(this_obj_conv);
15804 }
15805
15806 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
15807         LDKAnnouncementSignatures this_ptr_conv;
15808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15809         this_ptr_conv.is_owned = false;
15810         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15811         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
15812         return ret_arr;
15813 }
15814
15815 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15816         LDKAnnouncementSignatures this_ptr_conv;
15817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15818         this_ptr_conv.is_owned = false;
15819         LDKThirtyTwoBytes val_ref;
15820         CHECK(*((uint32_t*)val) == 32);
15821         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15822         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
15823 }
15824
15825 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
15826         LDKAnnouncementSignatures this_ptr_conv;
15827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15828         this_ptr_conv.is_owned = false;
15829         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
15830         return ret_val;
15831 }
15832
15833 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
15834         LDKAnnouncementSignatures this_ptr_conv;
15835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15836         this_ptr_conv.is_owned = false;
15837         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
15838 }
15839
15840 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
15841         LDKAnnouncementSignatures this_ptr_conv;
15842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15843         this_ptr_conv.is_owned = false;
15844         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15845         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
15846         return ret_arr;
15847 }
15848
15849 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
15850         LDKAnnouncementSignatures this_ptr_conv;
15851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15852         this_ptr_conv.is_owned = false;
15853         LDKSignature val_ref;
15854         CHECK(*((uint32_t*)val) == 64);
15855         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15856         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
15857 }
15858
15859 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
15860         LDKAnnouncementSignatures this_ptr_conv;
15861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15862         this_ptr_conv.is_owned = false;
15863         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
15864         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
15865         return ret_arr;
15866 }
15867
15868 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
15869         LDKAnnouncementSignatures this_ptr_conv;
15870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15871         this_ptr_conv.is_owned = false;
15872         LDKSignature val_ref;
15873         CHECK(*((uint32_t*)val) == 64);
15874         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
15875         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
15876 }
15877
15878 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) {
15879         LDKThirtyTwoBytes channel_id_arg_ref;
15880         CHECK(*((uint32_t*)channel_id_arg) == 32);
15881         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15882         LDKSignature node_signature_arg_ref;
15883         CHECK(*((uint32_t*)node_signature_arg) == 64);
15884         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
15885         LDKSignature bitcoin_signature_arg_ref;
15886         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
15887         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
15888         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
15889         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15890         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15891         uint64_t ret_ref = (uint64_t)ret_var.inner;
15892         if (ret_var.is_owned) {
15893                 ret_ref |= 1;
15894         }
15895         return ret_ref;
15896 }
15897
15898 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
15899         LDKAnnouncementSignatures orig_conv;
15900         orig_conv.inner = (void*)(orig & (~1));
15901         orig_conv.is_owned = false;
15902         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
15903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15905         uint64_t ret_ref = (uint64_t)ret_var.inner;
15906         if (ret_var.is_owned) {
15907                 ret_ref |= 1;
15908         }
15909         return ret_ref;
15910 }
15911
15912 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
15913         if ((this_ptr & 1) != 0) return;
15914         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
15915         FREE((void*)this_ptr);
15916         NetAddress_free(this_ptr_conv);
15917 }
15918
15919 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
15920         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
15921         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
15922         *ret_copy = NetAddress_clone(orig_conv);
15923         uint64_t ret_ref = (uint64_t)ret_copy;
15924         return ret_ref;
15925 }
15926
15927 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
15928         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
15929         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
15930         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15931         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15932         CVec_u8Z_free(ret_var);
15933         return ret_arr;
15934 }
15935
15936 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
15937         LDKu8slice ser_ref;
15938         ser_ref.datalen = *((uint32_t*)ser);
15939         ser_ref.data = (int8_t*)(ser + 4);
15940         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
15941         *ret_conv = Result_read(ser_ref);
15942         return (uint64_t)ret_conv;
15943 }
15944
15945 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
15946         LDKu8slice ser_ref;
15947         ser_ref.datalen = *((uint32_t*)ser);
15948         ser_ref.data = (int8_t*)(ser + 4);
15949         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
15950         *ret_conv = NetAddress_read(ser_ref);
15951         return (uint64_t)ret_conv;
15952 }
15953
15954 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
15955         LDKUnsignedNodeAnnouncement this_obj_conv;
15956         this_obj_conv.inner = (void*)(this_obj & (~1));
15957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15958         UnsignedNodeAnnouncement_free(this_obj_conv);
15959 }
15960
15961 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
15962         LDKUnsignedNodeAnnouncement this_ptr_conv;
15963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15964         this_ptr_conv.is_owned = false;
15965         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
15966         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15967         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15968         uint64_t ret_ref = (uint64_t)ret_var.inner;
15969         if (ret_var.is_owned) {
15970                 ret_ref |= 1;
15971         }
15972         return ret_ref;
15973 }
15974
15975 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
15976         LDKUnsignedNodeAnnouncement this_ptr_conv;
15977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15978         this_ptr_conv.is_owned = false;
15979         LDKNodeFeatures val_conv;
15980         val_conv.inner = (void*)(val & (~1));
15981         val_conv.is_owned = (val & 1) || (val == 0);
15982         val_conv = NodeFeatures_clone(&val_conv);
15983         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
15984 }
15985
15986 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
15987         LDKUnsignedNodeAnnouncement this_ptr_conv;
15988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15989         this_ptr_conv.is_owned = false;
15990         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
15991         return ret_val;
15992 }
15993
15994 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
15995         LDKUnsignedNodeAnnouncement this_ptr_conv;
15996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15997         this_ptr_conv.is_owned = false;
15998         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
15999 }
16000
16001 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
16002         LDKUnsignedNodeAnnouncement this_ptr_conv;
16003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16004         this_ptr_conv.is_owned = false;
16005         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16006         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
16007         return ret_arr;
16008 }
16009
16010 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
16011         LDKUnsignedNodeAnnouncement this_ptr_conv;
16012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16013         this_ptr_conv.is_owned = false;
16014         LDKPublicKey val_ref;
16015         CHECK(*((uint32_t*)val) == 33);
16016         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16017         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
16018 }
16019
16020 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
16021         LDKUnsignedNodeAnnouncement this_ptr_conv;
16022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16023         this_ptr_conv.is_owned = false;
16024         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
16025         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
16026         return ret_arr;
16027 }
16028
16029 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
16030         LDKUnsignedNodeAnnouncement this_ptr_conv;
16031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16032         this_ptr_conv.is_owned = false;
16033         LDKThreeBytes val_ref;
16034         CHECK(*((uint32_t*)val) == 3);
16035         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
16036         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
16037 }
16038
16039 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
16040         LDKUnsignedNodeAnnouncement this_ptr_conv;
16041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16042         this_ptr_conv.is_owned = false;
16043         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16044         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
16045         return ret_arr;
16046 }
16047
16048 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
16049         LDKUnsignedNodeAnnouncement this_ptr_conv;
16050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16051         this_ptr_conv.is_owned = false;
16052         LDKThirtyTwoBytes val_ref;
16053         CHECK(*((uint32_t*)val) == 32);
16054         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16055         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
16056 }
16057
16058 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
16059         LDKUnsignedNodeAnnouncement this_ptr_conv;
16060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16061         this_ptr_conv.is_owned = false;
16062         LDKCVec_NetAddressZ val_constr;
16063         val_constr.datalen = *((uint32_t*)val);
16064         if (val_constr.datalen > 0)
16065                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16066         else
16067                 val_constr.data = NULL;
16068         uint32_t* val_vals = (uint32_t*)(val + 4);
16069         for (size_t m = 0; m < val_constr.datalen; m++) {
16070                 uint32_t val_conv_12 = val_vals[m];
16071                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
16072                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
16073                 val_constr.data[m] = val_conv_12_conv;
16074         }
16075         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
16076 }
16077
16078 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
16079         LDKUnsignedNodeAnnouncement orig_conv;
16080         orig_conv.inner = (void*)(orig & (~1));
16081         orig_conv.is_owned = false;
16082         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
16083         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16084         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16085         uint64_t ret_ref = (uint64_t)ret_var.inner;
16086         if (ret_var.is_owned) {
16087                 ret_ref |= 1;
16088         }
16089         return ret_ref;
16090 }
16091
16092 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
16093         LDKNodeAnnouncement this_obj_conv;
16094         this_obj_conv.inner = (void*)(this_obj & (~1));
16095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16096         NodeAnnouncement_free(this_obj_conv);
16097 }
16098
16099 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
16100         LDKNodeAnnouncement this_ptr_conv;
16101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16102         this_ptr_conv.is_owned = false;
16103         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16104         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
16105         return ret_arr;
16106 }
16107
16108 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
16109         LDKNodeAnnouncement this_ptr_conv;
16110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16111         this_ptr_conv.is_owned = false;
16112         LDKSignature val_ref;
16113         CHECK(*((uint32_t*)val) == 64);
16114         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16115         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
16116 }
16117
16118 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
16119         LDKNodeAnnouncement this_ptr_conv;
16120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16121         this_ptr_conv.is_owned = false;
16122         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
16123         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16124         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16125         uint64_t ret_ref = (uint64_t)ret_var.inner;
16126         if (ret_var.is_owned) {
16127                 ret_ref |= 1;
16128         }
16129         return ret_ref;
16130 }
16131
16132 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16133         LDKNodeAnnouncement this_ptr_conv;
16134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16135         this_ptr_conv.is_owned = false;
16136         LDKUnsignedNodeAnnouncement val_conv;
16137         val_conv.inner = (void*)(val & (~1));
16138         val_conv.is_owned = (val & 1) || (val == 0);
16139         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
16140         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
16141 }
16142
16143 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
16144         LDKSignature signature_arg_ref;
16145         CHECK(*((uint32_t*)signature_arg) == 64);
16146         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16147         LDKUnsignedNodeAnnouncement contents_arg_conv;
16148         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16149         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16150         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
16151         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
16152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16154         uint64_t ret_ref = (uint64_t)ret_var.inner;
16155         if (ret_var.is_owned) {
16156                 ret_ref |= 1;
16157         }
16158         return ret_ref;
16159 }
16160
16161 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
16162         LDKNodeAnnouncement orig_conv;
16163         orig_conv.inner = (void*)(orig & (~1));
16164         orig_conv.is_owned = false;
16165         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
16166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16168         uint64_t ret_ref = (uint64_t)ret_var.inner;
16169         if (ret_var.is_owned) {
16170                 ret_ref |= 1;
16171         }
16172         return ret_ref;
16173 }
16174
16175 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
16176         LDKUnsignedChannelAnnouncement this_obj_conv;
16177         this_obj_conv.inner = (void*)(this_obj & (~1));
16178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16179         UnsignedChannelAnnouncement_free(this_obj_conv);
16180 }
16181
16182 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
16183         LDKUnsignedChannelAnnouncement this_ptr_conv;
16184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16185         this_ptr_conv.is_owned = false;
16186         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
16187         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16188         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16189         uint64_t ret_ref = (uint64_t)ret_var.inner;
16190         if (ret_var.is_owned) {
16191                 ret_ref |= 1;
16192         }
16193         return ret_ref;
16194 }
16195
16196 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
16197         LDKUnsignedChannelAnnouncement this_ptr_conv;
16198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16199         this_ptr_conv.is_owned = false;
16200         LDKChannelFeatures val_conv;
16201         val_conv.inner = (void*)(val & (~1));
16202         val_conv.is_owned = (val & 1) || (val == 0);
16203         val_conv = ChannelFeatures_clone(&val_conv);
16204         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
16205 }
16206
16207 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
16208         LDKUnsignedChannelAnnouncement this_ptr_conv;
16209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16210         this_ptr_conv.is_owned = false;
16211         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16212         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
16213         return ret_arr;
16214 }
16215
16216 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16217         LDKUnsignedChannelAnnouncement this_ptr_conv;
16218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16219         this_ptr_conv.is_owned = false;
16220         LDKThirtyTwoBytes val_ref;
16221         CHECK(*((uint32_t*)val) == 32);
16222         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16223         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
16224 }
16225
16226 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
16227         LDKUnsignedChannelAnnouncement this_ptr_conv;
16228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16229         this_ptr_conv.is_owned = false;
16230         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
16231         return ret_val;
16232 }
16233
16234 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16235         LDKUnsignedChannelAnnouncement this_ptr_conv;
16236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16237         this_ptr_conv.is_owned = false;
16238         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
16239 }
16240
16241 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
16242         LDKUnsignedChannelAnnouncement this_ptr_conv;
16243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16244         this_ptr_conv.is_owned = false;
16245         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16246         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
16247         return ret_arr;
16248 }
16249
16250 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
16251         LDKUnsignedChannelAnnouncement this_ptr_conv;
16252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16253         this_ptr_conv.is_owned = false;
16254         LDKPublicKey val_ref;
16255         CHECK(*((uint32_t*)val) == 33);
16256         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16257         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
16258 }
16259
16260 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
16261         LDKUnsignedChannelAnnouncement this_ptr_conv;
16262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16263         this_ptr_conv.is_owned = false;
16264         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16265         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
16266         return ret_arr;
16267 }
16268
16269 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
16270         LDKUnsignedChannelAnnouncement this_ptr_conv;
16271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16272         this_ptr_conv.is_owned = false;
16273         LDKPublicKey val_ref;
16274         CHECK(*((uint32_t*)val) == 33);
16275         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16276         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
16277 }
16278
16279 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
16280         LDKUnsignedChannelAnnouncement this_ptr_conv;
16281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16282         this_ptr_conv.is_owned = false;
16283         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16284         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
16285         return ret_arr;
16286 }
16287
16288 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
16289         LDKUnsignedChannelAnnouncement this_ptr_conv;
16290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16291         this_ptr_conv.is_owned = false;
16292         LDKPublicKey val_ref;
16293         CHECK(*((uint32_t*)val) == 33);
16294         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16295         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
16296 }
16297
16298 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
16299         LDKUnsignedChannelAnnouncement this_ptr_conv;
16300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16301         this_ptr_conv.is_owned = false;
16302         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16303         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
16304         return ret_arr;
16305 }
16306
16307 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
16308         LDKUnsignedChannelAnnouncement this_ptr_conv;
16309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16310         this_ptr_conv.is_owned = false;
16311         LDKPublicKey val_ref;
16312         CHECK(*((uint32_t*)val) == 33);
16313         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16314         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
16315 }
16316
16317 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
16318         LDKUnsignedChannelAnnouncement orig_conv;
16319         orig_conv.inner = (void*)(orig & (~1));
16320         orig_conv.is_owned = false;
16321         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
16322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16324         uint64_t ret_ref = (uint64_t)ret_var.inner;
16325         if (ret_var.is_owned) {
16326                 ret_ref |= 1;
16327         }
16328         return ret_ref;
16329 }
16330
16331 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
16332         LDKChannelAnnouncement this_obj_conv;
16333         this_obj_conv.inner = (void*)(this_obj & (~1));
16334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16335         ChannelAnnouncement_free(this_obj_conv);
16336 }
16337
16338 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
16339         LDKChannelAnnouncement this_ptr_conv;
16340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16341         this_ptr_conv.is_owned = false;
16342         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16343         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
16344         return ret_arr;
16345 }
16346
16347 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
16348         LDKChannelAnnouncement this_ptr_conv;
16349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16350         this_ptr_conv.is_owned = false;
16351         LDKSignature val_ref;
16352         CHECK(*((uint32_t*)val) == 64);
16353         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16354         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
16355 }
16356
16357 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
16358         LDKChannelAnnouncement this_ptr_conv;
16359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16360         this_ptr_conv.is_owned = false;
16361         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16362         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
16363         return ret_arr;
16364 }
16365
16366 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
16367         LDKChannelAnnouncement this_ptr_conv;
16368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16369         this_ptr_conv.is_owned = false;
16370         LDKSignature val_ref;
16371         CHECK(*((uint32_t*)val) == 64);
16372         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16373         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
16374 }
16375
16376 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
16377         LDKChannelAnnouncement this_ptr_conv;
16378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16379         this_ptr_conv.is_owned = false;
16380         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16381         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
16382         return ret_arr;
16383 }
16384
16385 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
16386         LDKChannelAnnouncement this_ptr_conv;
16387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16388         this_ptr_conv.is_owned = false;
16389         LDKSignature val_ref;
16390         CHECK(*((uint32_t*)val) == 64);
16391         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16392         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
16393 }
16394
16395 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
16396         LDKChannelAnnouncement this_ptr_conv;
16397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16398         this_ptr_conv.is_owned = false;
16399         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16400         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
16401         return ret_arr;
16402 }
16403
16404 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
16405         LDKChannelAnnouncement this_ptr_conv;
16406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16407         this_ptr_conv.is_owned = false;
16408         LDKSignature val_ref;
16409         CHECK(*((uint32_t*)val) == 64);
16410         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16411         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
16412 }
16413
16414 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
16415         LDKChannelAnnouncement this_ptr_conv;
16416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16417         this_ptr_conv.is_owned = false;
16418         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
16419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16421         uint64_t ret_ref = (uint64_t)ret_var.inner;
16422         if (ret_var.is_owned) {
16423                 ret_ref |= 1;
16424         }
16425         return ret_ref;
16426 }
16427
16428 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
16429         LDKChannelAnnouncement this_ptr_conv;
16430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16431         this_ptr_conv.is_owned = false;
16432         LDKUnsignedChannelAnnouncement val_conv;
16433         val_conv.inner = (void*)(val & (~1));
16434         val_conv.is_owned = (val & 1) || (val == 0);
16435         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
16436         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
16437 }
16438
16439 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) {
16440         LDKSignature node_signature_1_arg_ref;
16441         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
16442         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
16443         LDKSignature node_signature_2_arg_ref;
16444         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
16445         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
16446         LDKSignature bitcoin_signature_1_arg_ref;
16447         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
16448         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
16449         LDKSignature bitcoin_signature_2_arg_ref;
16450         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
16451         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
16452         LDKUnsignedChannelAnnouncement contents_arg_conv;
16453         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16454         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16455         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
16456         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);
16457         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16458         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16459         uint64_t ret_ref = (uint64_t)ret_var.inner;
16460         if (ret_var.is_owned) {
16461                 ret_ref |= 1;
16462         }
16463         return ret_ref;
16464 }
16465
16466 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
16467         LDKChannelAnnouncement orig_conv;
16468         orig_conv.inner = (void*)(orig & (~1));
16469         orig_conv.is_owned = false;
16470         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
16471         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16472         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16473         uint64_t ret_ref = (uint64_t)ret_var.inner;
16474         if (ret_var.is_owned) {
16475                 ret_ref |= 1;
16476         }
16477         return ret_ref;
16478 }
16479
16480 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
16481         LDKUnsignedChannelUpdate this_obj_conv;
16482         this_obj_conv.inner = (void*)(this_obj & (~1));
16483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16484         UnsignedChannelUpdate_free(this_obj_conv);
16485 }
16486
16487 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
16488         LDKUnsignedChannelUpdate this_ptr_conv;
16489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16490         this_ptr_conv.is_owned = false;
16491         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16492         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
16493         return ret_arr;
16494 }
16495
16496 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16497         LDKUnsignedChannelUpdate this_ptr_conv;
16498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16499         this_ptr_conv.is_owned = false;
16500         LDKThirtyTwoBytes val_ref;
16501         CHECK(*((uint32_t*)val) == 32);
16502         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16503         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
16504 }
16505
16506 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
16507         LDKUnsignedChannelUpdate this_ptr_conv;
16508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16509         this_ptr_conv.is_owned = false;
16510         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
16511         return ret_val;
16512 }
16513
16514 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
16515         LDKUnsignedChannelUpdate this_ptr_conv;
16516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16517         this_ptr_conv.is_owned = false;
16518         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
16519 }
16520
16521 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
16522         LDKUnsignedChannelUpdate this_ptr_conv;
16523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16524         this_ptr_conv.is_owned = false;
16525         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
16526         return ret_val;
16527 }
16528
16529 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
16530         LDKUnsignedChannelUpdate this_ptr_conv;
16531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16532         this_ptr_conv.is_owned = false;
16533         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
16534 }
16535
16536 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
16537         LDKUnsignedChannelUpdate this_ptr_conv;
16538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16539         this_ptr_conv.is_owned = false;
16540         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
16541         return ret_val;
16542 }
16543
16544 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
16545         LDKUnsignedChannelUpdate this_ptr_conv;
16546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16547         this_ptr_conv.is_owned = false;
16548         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
16549 }
16550
16551 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
16552         LDKUnsignedChannelUpdate this_ptr_conv;
16553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16554         this_ptr_conv.is_owned = false;
16555         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
16556         return ret_val;
16557 }
16558
16559 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
16560         LDKUnsignedChannelUpdate this_ptr_conv;
16561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16562         this_ptr_conv.is_owned = false;
16563         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
16564 }
16565
16566 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
16567         LDKUnsignedChannelUpdate this_ptr_conv;
16568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16569         this_ptr_conv.is_owned = false;
16570         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
16571         return ret_val;
16572 }
16573
16574 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16575         LDKUnsignedChannelUpdate this_ptr_conv;
16576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16577         this_ptr_conv.is_owned = false;
16578         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
16579 }
16580
16581 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
16582         LDKUnsignedChannelUpdate this_ptr_conv;
16583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16584         this_ptr_conv.is_owned = false;
16585         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
16586         return ret_val;
16587 }
16588
16589 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
16590         LDKUnsignedChannelUpdate this_ptr_conv;
16591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16592         this_ptr_conv.is_owned = false;
16593         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
16594 }
16595
16596 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
16597         LDKUnsignedChannelUpdate this_ptr_conv;
16598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16599         this_ptr_conv.is_owned = false;
16600         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
16601         return ret_val;
16602 }
16603
16604 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
16605         LDKUnsignedChannelUpdate this_ptr_conv;
16606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16607         this_ptr_conv.is_owned = false;
16608         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
16609 }
16610
16611 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
16612         LDKUnsignedChannelUpdate orig_conv;
16613         orig_conv.inner = (void*)(orig & (~1));
16614         orig_conv.is_owned = false;
16615         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
16616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16618         uint64_t ret_ref = (uint64_t)ret_var.inner;
16619         if (ret_var.is_owned) {
16620                 ret_ref |= 1;
16621         }
16622         return ret_ref;
16623 }
16624
16625 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
16626         LDKChannelUpdate this_obj_conv;
16627         this_obj_conv.inner = (void*)(this_obj & (~1));
16628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16629         ChannelUpdate_free(this_obj_conv);
16630 }
16631
16632 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
16633         LDKChannelUpdate this_ptr_conv;
16634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16635         this_ptr_conv.is_owned = false;
16636         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16637         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
16638         return ret_arr;
16639 }
16640
16641 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
16642         LDKChannelUpdate this_ptr_conv;
16643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16644         this_ptr_conv.is_owned = false;
16645         LDKSignature val_ref;
16646         CHECK(*((uint32_t*)val) == 64);
16647         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16648         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
16649 }
16650
16651 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
16652         LDKChannelUpdate this_ptr_conv;
16653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16654         this_ptr_conv.is_owned = false;
16655         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
16656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16658         uint64_t ret_ref = (uint64_t)ret_var.inner;
16659         if (ret_var.is_owned) {
16660                 ret_ref |= 1;
16661         }
16662         return ret_ref;
16663 }
16664
16665 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
16666         LDKChannelUpdate this_ptr_conv;
16667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16668         this_ptr_conv.is_owned = false;
16669         LDKUnsignedChannelUpdate val_conv;
16670         val_conv.inner = (void*)(val & (~1));
16671         val_conv.is_owned = (val & 1) || (val == 0);
16672         val_conv = UnsignedChannelUpdate_clone(&val_conv);
16673         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
16674 }
16675
16676 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
16677         LDKSignature signature_arg_ref;
16678         CHECK(*((uint32_t*)signature_arg) == 64);
16679         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
16680         LDKUnsignedChannelUpdate contents_arg_conv;
16681         contents_arg_conv.inner = (void*)(contents_arg & (~1));
16682         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
16683         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
16684         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
16685         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16686         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16687         uint64_t ret_ref = (uint64_t)ret_var.inner;
16688         if (ret_var.is_owned) {
16689                 ret_ref |= 1;
16690         }
16691         return ret_ref;
16692 }
16693
16694 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
16695         LDKChannelUpdate orig_conv;
16696         orig_conv.inner = (void*)(orig & (~1));
16697         orig_conv.is_owned = false;
16698         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
16699         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16700         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16701         uint64_t ret_ref = (uint64_t)ret_var.inner;
16702         if (ret_var.is_owned) {
16703                 ret_ref |= 1;
16704         }
16705         return ret_ref;
16706 }
16707
16708 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
16709         LDKQueryChannelRange this_obj_conv;
16710         this_obj_conv.inner = (void*)(this_obj & (~1));
16711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16712         QueryChannelRange_free(this_obj_conv);
16713 }
16714
16715 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
16716         LDKQueryChannelRange this_ptr_conv;
16717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16718         this_ptr_conv.is_owned = false;
16719         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16720         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
16721         return ret_arr;
16722 }
16723
16724 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16725         LDKQueryChannelRange this_ptr_conv;
16726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16727         this_ptr_conv.is_owned = false;
16728         LDKThirtyTwoBytes val_ref;
16729         CHECK(*((uint32_t*)val) == 32);
16730         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16731         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16732 }
16733
16734 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
16735         LDKQueryChannelRange this_ptr_conv;
16736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16737         this_ptr_conv.is_owned = false;
16738         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
16739         return ret_val;
16740 }
16741
16742 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16743         LDKQueryChannelRange this_ptr_conv;
16744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16745         this_ptr_conv.is_owned = false;
16746         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
16747 }
16748
16749 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
16750         LDKQueryChannelRange this_ptr_conv;
16751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16752         this_ptr_conv.is_owned = false;
16753         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
16754         return ret_val;
16755 }
16756
16757 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
16758         LDKQueryChannelRange this_ptr_conv;
16759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16760         this_ptr_conv.is_owned = false;
16761         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16762 }
16763
16764 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
16765         LDKThirtyTwoBytes chain_hash_arg_ref;
16766         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16767         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16768         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
16769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16771         uint64_t ret_ref = (uint64_t)ret_var.inner;
16772         if (ret_var.is_owned) {
16773                 ret_ref |= 1;
16774         }
16775         return ret_ref;
16776 }
16777
16778 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
16779         LDKQueryChannelRange orig_conv;
16780         orig_conv.inner = (void*)(orig & (~1));
16781         orig_conv.is_owned = false;
16782         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
16783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16785         uint64_t ret_ref = (uint64_t)ret_var.inner;
16786         if (ret_var.is_owned) {
16787                 ret_ref |= 1;
16788         }
16789         return ret_ref;
16790 }
16791
16792 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
16793         LDKReplyChannelRange this_obj_conv;
16794         this_obj_conv.inner = (void*)(this_obj & (~1));
16795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16796         ReplyChannelRange_free(this_obj_conv);
16797 }
16798
16799 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
16800         LDKReplyChannelRange this_ptr_conv;
16801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16802         this_ptr_conv.is_owned = false;
16803         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16804         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
16805         return ret_arr;
16806 }
16807
16808 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16809         LDKReplyChannelRange this_ptr_conv;
16810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16811         this_ptr_conv.is_owned = false;
16812         LDKThirtyTwoBytes val_ref;
16813         CHECK(*((uint32_t*)val) == 32);
16814         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16815         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
16816 }
16817
16818 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
16819         LDKReplyChannelRange this_ptr_conv;
16820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16821         this_ptr_conv.is_owned = false;
16822         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
16823         return ret_val;
16824 }
16825
16826 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
16827         LDKReplyChannelRange this_ptr_conv;
16828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16829         this_ptr_conv.is_owned = false;
16830         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
16831 }
16832
16833 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
16834         LDKReplyChannelRange this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
16838         return ret_val;
16839 }
16840
16841 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
16842         LDKReplyChannelRange this_ptr_conv;
16843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16844         this_ptr_conv.is_owned = false;
16845         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
16846 }
16847
16848 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
16849         LDKReplyChannelRange this_ptr_conv;
16850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16851         this_ptr_conv.is_owned = false;
16852         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
16853         return ret_val;
16854 }
16855
16856 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
16857         LDKReplyChannelRange this_ptr_conv;
16858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16859         this_ptr_conv.is_owned = false;
16860         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
16861 }
16862
16863 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
16864         LDKReplyChannelRange this_ptr_conv;
16865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16866         this_ptr_conv.is_owned = false;
16867         LDKCVec_u64Z val_constr;
16868         val_constr.datalen = *((uint32_t*)val);
16869         if (val_constr.datalen > 0)
16870                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16871         else
16872                 val_constr.data = NULL;
16873         int64_t* val_vals = (int64_t*)(val + 4);
16874         for (size_t i = 0; i < val_constr.datalen; i++) {
16875                 int64_t val_conv_8 = val_vals[i];
16876                 val_constr.data[i] = val_conv_8;
16877         }
16878         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
16879 }
16880
16881 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) {
16882         LDKThirtyTwoBytes chain_hash_arg_ref;
16883         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16884         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16885         LDKCVec_u64Z short_channel_ids_arg_constr;
16886         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
16887         if (short_channel_ids_arg_constr.datalen > 0)
16888                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16889         else
16890                 short_channel_ids_arg_constr.data = NULL;
16891         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
16892         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
16893                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
16894                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
16895         }
16896         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
16897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16899         uint64_t ret_ref = (uint64_t)ret_var.inner;
16900         if (ret_var.is_owned) {
16901                 ret_ref |= 1;
16902         }
16903         return ret_ref;
16904 }
16905
16906 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
16907         LDKReplyChannelRange orig_conv;
16908         orig_conv.inner = (void*)(orig & (~1));
16909         orig_conv.is_owned = false;
16910         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
16911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16913         uint64_t ret_ref = (uint64_t)ret_var.inner;
16914         if (ret_var.is_owned) {
16915                 ret_ref |= 1;
16916         }
16917         return ret_ref;
16918 }
16919
16920 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
16921         LDKQueryShortChannelIds this_obj_conv;
16922         this_obj_conv.inner = (void*)(this_obj & (~1));
16923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16924         QueryShortChannelIds_free(this_obj_conv);
16925 }
16926
16927 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
16928         LDKQueryShortChannelIds this_ptr_conv;
16929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16930         this_ptr_conv.is_owned = false;
16931         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16932         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
16933         return ret_arr;
16934 }
16935
16936 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16937         LDKQueryShortChannelIds this_ptr_conv;
16938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16939         this_ptr_conv.is_owned = false;
16940         LDKThirtyTwoBytes val_ref;
16941         CHECK(*((uint32_t*)val) == 32);
16942         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16943         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
16944 }
16945
16946 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
16947         LDKQueryShortChannelIds this_ptr_conv;
16948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16949         this_ptr_conv.is_owned = false;
16950         LDKCVec_u64Z val_constr;
16951         val_constr.datalen = *((uint32_t*)val);
16952         if (val_constr.datalen > 0)
16953                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16954         else
16955                 val_constr.data = NULL;
16956         int64_t* val_vals = (int64_t*)(val + 4);
16957         for (size_t i = 0; i < val_constr.datalen; i++) {
16958                 int64_t val_conv_8 = val_vals[i];
16959                 val_constr.data[i] = val_conv_8;
16960         }
16961         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
16962 }
16963
16964 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
16965         LDKThirtyTwoBytes chain_hash_arg_ref;
16966         CHECK(*((uint32_t*)chain_hash_arg) == 32);
16967         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
16968         LDKCVec_u64Z short_channel_ids_arg_constr;
16969         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
16970         if (short_channel_ids_arg_constr.datalen > 0)
16971                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16972         else
16973                 short_channel_ids_arg_constr.data = NULL;
16974         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
16975         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
16976                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
16977                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
16978         }
16979         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
16980         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16981         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16982         uint64_t ret_ref = (uint64_t)ret_var.inner;
16983         if (ret_var.is_owned) {
16984                 ret_ref |= 1;
16985         }
16986         return ret_ref;
16987 }
16988
16989 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
16990         LDKQueryShortChannelIds orig_conv;
16991         orig_conv.inner = (void*)(orig & (~1));
16992         orig_conv.is_owned = false;
16993         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
16994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16996         uint64_t ret_ref = (uint64_t)ret_var.inner;
16997         if (ret_var.is_owned) {
16998                 ret_ref |= 1;
16999         }
17000         return ret_ref;
17001 }
17002
17003 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
17004         LDKReplyShortChannelIdsEnd this_obj_conv;
17005         this_obj_conv.inner = (void*)(this_obj & (~1));
17006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17007         ReplyShortChannelIdsEnd_free(this_obj_conv);
17008 }
17009
17010 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
17011         LDKReplyShortChannelIdsEnd this_ptr_conv;
17012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17013         this_ptr_conv.is_owned = false;
17014         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17015         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
17016         return ret_arr;
17017 }
17018
17019 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17020         LDKReplyShortChannelIdsEnd this_ptr_conv;
17021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17022         this_ptr_conv.is_owned = false;
17023         LDKThirtyTwoBytes val_ref;
17024         CHECK(*((uint32_t*)val) == 32);
17025         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17026         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
17027 }
17028
17029 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
17030         LDKReplyShortChannelIdsEnd this_ptr_conv;
17031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17032         this_ptr_conv.is_owned = false;
17033         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
17034         return ret_val;
17035 }
17036
17037 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
17038         LDKReplyShortChannelIdsEnd this_ptr_conv;
17039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17040         this_ptr_conv.is_owned = false;
17041         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
17042 }
17043
17044 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
17045         LDKThirtyTwoBytes chain_hash_arg_ref;
17046         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17047         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17048         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
17049         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17050         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17051         uint64_t ret_ref = (uint64_t)ret_var.inner;
17052         if (ret_var.is_owned) {
17053                 ret_ref |= 1;
17054         }
17055         return ret_ref;
17056 }
17057
17058 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
17059         LDKReplyShortChannelIdsEnd orig_conv;
17060         orig_conv.inner = (void*)(orig & (~1));
17061         orig_conv.is_owned = false;
17062         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
17063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17065         uint64_t ret_ref = (uint64_t)ret_var.inner;
17066         if (ret_var.is_owned) {
17067                 ret_ref |= 1;
17068         }
17069         return ret_ref;
17070 }
17071
17072 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
17073         LDKGossipTimestampFilter this_obj_conv;
17074         this_obj_conv.inner = (void*)(this_obj & (~1));
17075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17076         GossipTimestampFilter_free(this_obj_conv);
17077 }
17078
17079 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
17080         LDKGossipTimestampFilter this_ptr_conv;
17081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17082         this_ptr_conv.is_owned = false;
17083         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17084         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
17085         return ret_arr;
17086 }
17087
17088 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17089         LDKGossipTimestampFilter this_ptr_conv;
17090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17091         this_ptr_conv.is_owned = false;
17092         LDKThirtyTwoBytes val_ref;
17093         CHECK(*((uint32_t*)val) == 32);
17094         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17095         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
17096 }
17097
17098 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
17099         LDKGossipTimestampFilter this_ptr_conv;
17100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17101         this_ptr_conv.is_owned = false;
17102         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
17103         return ret_val;
17104 }
17105
17106 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
17107         LDKGossipTimestampFilter this_ptr_conv;
17108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17109         this_ptr_conv.is_owned = false;
17110         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
17111 }
17112
17113 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
17114         LDKGossipTimestampFilter this_ptr_conv;
17115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17116         this_ptr_conv.is_owned = false;
17117         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
17118         return ret_val;
17119 }
17120
17121 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
17122         LDKGossipTimestampFilter this_ptr_conv;
17123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17124         this_ptr_conv.is_owned = false;
17125         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
17126 }
17127
17128 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
17129         LDKThirtyTwoBytes chain_hash_arg_ref;
17130         CHECK(*((uint32_t*)chain_hash_arg) == 32);
17131         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
17132         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
17133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17135         uint64_t ret_ref = (uint64_t)ret_var.inner;
17136         if (ret_var.is_owned) {
17137                 ret_ref |= 1;
17138         }
17139         return ret_ref;
17140 }
17141
17142 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
17143         LDKGossipTimestampFilter orig_conv;
17144         orig_conv.inner = (void*)(orig & (~1));
17145         orig_conv.is_owned = false;
17146         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
17147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17149         uint64_t ret_ref = (uint64_t)ret_var.inner;
17150         if (ret_var.is_owned) {
17151                 ret_ref |= 1;
17152         }
17153         return ret_ref;
17154 }
17155
17156 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
17157         if ((this_ptr & 1) != 0) return;
17158         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
17159         FREE((void*)this_ptr);
17160         ErrorAction_free(this_ptr_conv);
17161 }
17162
17163 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
17164         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
17165         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17166         *ret_copy = ErrorAction_clone(orig_conv);
17167         uint64_t ret_ref = (uint64_t)ret_copy;
17168         return ret_ref;
17169 }
17170
17171 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
17172         LDKLightningError this_obj_conv;
17173         this_obj_conv.inner = (void*)(this_obj & (~1));
17174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17175         LightningError_free(this_obj_conv);
17176 }
17177
17178 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
17179         LDKLightningError this_ptr_conv;
17180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17181         this_ptr_conv.is_owned = false;
17182         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
17183         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17184         return ret_conv;
17185 }
17186
17187 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
17188         LDKLightningError this_ptr_conv;
17189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17190         this_ptr_conv.is_owned = false;
17191         LDKStr val_conv = str_ref_to_owned_c(val);
17192         LightningError_set_err(&this_ptr_conv, val_conv);
17193 }
17194
17195 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
17196         LDKLightningError this_ptr_conv;
17197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17198         this_ptr_conv.is_owned = false;
17199         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
17200         *ret_copy = LightningError_get_action(&this_ptr_conv);
17201         uint64_t ret_ref = (uint64_t)ret_copy;
17202         return ret_ref;
17203 }
17204
17205 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
17206         LDKLightningError this_ptr_conv;
17207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17208         this_ptr_conv.is_owned = false;
17209         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
17210         LightningError_set_action(&this_ptr_conv, val_conv);
17211 }
17212
17213 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
17214         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
17215         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
17216         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
17217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17219         uint64_t ret_ref = (uint64_t)ret_var.inner;
17220         if (ret_var.is_owned) {
17221                 ret_ref |= 1;
17222         }
17223         return ret_ref;
17224 }
17225
17226 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
17227         LDKLightningError orig_conv;
17228         orig_conv.inner = (void*)(orig & (~1));
17229         orig_conv.is_owned = false;
17230         LDKLightningError ret_var = LightningError_clone(&orig_conv);
17231         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17232         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17233         uint64_t ret_ref = (uint64_t)ret_var.inner;
17234         if (ret_var.is_owned) {
17235                 ret_ref |= 1;
17236         }
17237         return ret_ref;
17238 }
17239
17240 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
17241         LDKCommitmentUpdate this_obj_conv;
17242         this_obj_conv.inner = (void*)(this_obj & (~1));
17243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17244         CommitmentUpdate_free(this_obj_conv);
17245 }
17246
17247 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
17248         LDKCommitmentUpdate this_ptr_conv;
17249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17250         this_ptr_conv.is_owned = false;
17251         LDKCVec_UpdateAddHTLCZ val_constr;
17252         val_constr.datalen = *((uint32_t*)val);
17253         if (val_constr.datalen > 0)
17254                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17255         else
17256                 val_constr.data = NULL;
17257         uint32_t* val_vals = (uint32_t*)(val + 4);
17258         for (size_t p = 0; p < val_constr.datalen; p++) {
17259                 uint32_t val_conv_15 = val_vals[p];
17260                 LDKUpdateAddHTLC val_conv_15_conv;
17261                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
17262                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
17263                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
17264                 val_constr.data[p] = val_conv_15_conv;
17265         }
17266         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
17267 }
17268
17269 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
17270         LDKCommitmentUpdate this_ptr_conv;
17271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17272         this_ptr_conv.is_owned = false;
17273         LDKCVec_UpdateFulfillHTLCZ val_constr;
17274         val_constr.datalen = *((uint32_t*)val);
17275         if (val_constr.datalen > 0)
17276                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17277         else
17278                 val_constr.data = NULL;
17279         uint32_t* val_vals = (uint32_t*)(val + 4);
17280         for (size_t t = 0; t < val_constr.datalen; t++) {
17281                 uint32_t val_conv_19 = val_vals[t];
17282                 LDKUpdateFulfillHTLC val_conv_19_conv;
17283                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
17284                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
17285                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
17286                 val_constr.data[t] = val_conv_19_conv;
17287         }
17288         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
17289 }
17290
17291 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
17292         LDKCommitmentUpdate this_ptr_conv;
17293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17294         this_ptr_conv.is_owned = false;
17295         LDKCVec_UpdateFailHTLCZ val_constr;
17296         val_constr.datalen = *((uint32_t*)val);
17297         if (val_constr.datalen > 0)
17298                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17299         else
17300                 val_constr.data = NULL;
17301         uint32_t* val_vals = (uint32_t*)(val + 4);
17302         for (size_t q = 0; q < val_constr.datalen; q++) {
17303                 uint32_t val_conv_16 = val_vals[q];
17304                 LDKUpdateFailHTLC val_conv_16_conv;
17305                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
17306                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
17307                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
17308                 val_constr.data[q] = val_conv_16_conv;
17309         }
17310         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
17311 }
17312
17313 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
17314         LDKCommitmentUpdate this_ptr_conv;
17315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17316         this_ptr_conv.is_owned = false;
17317         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
17318         val_constr.datalen = *((uint32_t*)val);
17319         if (val_constr.datalen > 0)
17320                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17321         else
17322                 val_constr.data = NULL;
17323         uint32_t* val_vals = (uint32_t*)(val + 4);
17324         for (size_t z = 0; z < val_constr.datalen; z++) {
17325                 uint32_t val_conv_25 = val_vals[z];
17326                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
17327                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
17328                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
17329                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
17330                 val_constr.data[z] = val_conv_25_conv;
17331         }
17332         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
17333 }
17334
17335 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
17336         LDKCommitmentUpdate this_ptr_conv;
17337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17338         this_ptr_conv.is_owned = false;
17339         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
17340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17342         uint64_t ret_ref = (uint64_t)ret_var.inner;
17343         if (ret_var.is_owned) {
17344                 ret_ref |= 1;
17345         }
17346         return ret_ref;
17347 }
17348
17349 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
17350         LDKCommitmentUpdate this_ptr_conv;
17351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17352         this_ptr_conv.is_owned = false;
17353         LDKUpdateFee val_conv;
17354         val_conv.inner = (void*)(val & (~1));
17355         val_conv.is_owned = (val & 1) || (val == 0);
17356         val_conv = UpdateFee_clone(&val_conv);
17357         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
17358 }
17359
17360 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
17361         LDKCommitmentUpdate this_ptr_conv;
17362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17363         this_ptr_conv.is_owned = false;
17364         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
17365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17367         uint64_t ret_ref = (uint64_t)ret_var.inner;
17368         if (ret_var.is_owned) {
17369                 ret_ref |= 1;
17370         }
17371         return ret_ref;
17372 }
17373
17374 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
17375         LDKCommitmentUpdate this_ptr_conv;
17376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17377         this_ptr_conv.is_owned = false;
17378         LDKCommitmentSigned val_conv;
17379         val_conv.inner = (void*)(val & (~1));
17380         val_conv.is_owned = (val & 1) || (val == 0);
17381         val_conv = CommitmentSigned_clone(&val_conv);
17382         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
17383 }
17384
17385 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) {
17386         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
17387         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
17388         if (update_add_htlcs_arg_constr.datalen > 0)
17389                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17390         else
17391                 update_add_htlcs_arg_constr.data = NULL;
17392         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
17393         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
17394                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
17395                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
17396                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
17397                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
17398                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
17399                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
17400         }
17401         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
17402         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
17403         if (update_fulfill_htlcs_arg_constr.datalen > 0)
17404                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17405         else
17406                 update_fulfill_htlcs_arg_constr.data = NULL;
17407         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
17408         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
17409                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
17410                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
17411                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
17412                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
17413                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
17414                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
17415         }
17416         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
17417         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
17418         if (update_fail_htlcs_arg_constr.datalen > 0)
17419                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17420         else
17421                 update_fail_htlcs_arg_constr.data = NULL;
17422         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
17423         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
17424                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
17425                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
17426                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
17427                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
17428                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
17429                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
17430         }
17431         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
17432         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
17433         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
17434                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17435         else
17436                 update_fail_malformed_htlcs_arg_constr.data = NULL;
17437         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
17438         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
17439                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
17440                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
17441                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
17442                 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);
17443                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
17444                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
17445         }
17446         LDKUpdateFee update_fee_arg_conv;
17447         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
17448         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
17449         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
17450         LDKCommitmentSigned commitment_signed_arg_conv;
17451         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
17452         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
17453         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
17454         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);
17455         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17456         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17457         uint64_t ret_ref = (uint64_t)ret_var.inner;
17458         if (ret_var.is_owned) {
17459                 ret_ref |= 1;
17460         }
17461         return ret_ref;
17462 }
17463
17464 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
17465         LDKCommitmentUpdate orig_conv;
17466         orig_conv.inner = (void*)(orig & (~1));
17467         orig_conv.is_owned = false;
17468         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_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 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
17479         if ((this_ptr & 1) != 0) return;
17480         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
17481         FREE((void*)this_ptr);
17482         HTLCFailChannelUpdate_free(this_ptr_conv);
17483 }
17484
17485 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
17486         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
17487         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
17488         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
17489         uint64_t ret_ref = (uint64_t)ret_copy;
17490         return ret_ref;
17491 }
17492
17493 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
17494         if ((this_ptr & 1) != 0) return;
17495         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
17496         FREE((void*)this_ptr);
17497         ChannelMessageHandler_free(this_ptr_conv);
17498 }
17499
17500 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
17501         if ((this_ptr & 1) != 0) return;
17502         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
17503         FREE((void*)this_ptr);
17504         RoutingMessageHandler_free(this_ptr_conv);
17505 }
17506
17507 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
17508         LDKAcceptChannel obj_conv;
17509         obj_conv.inner = (void*)(obj & (~1));
17510         obj_conv.is_owned = false;
17511         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
17512         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17513         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17514         CVec_u8Z_free(ret_var);
17515         return ret_arr;
17516 }
17517
17518 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
17519         LDKu8slice ser_ref;
17520         ser_ref.datalen = *((uint32_t*)ser);
17521         ser_ref.data = (int8_t*)(ser + 4);
17522         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17523         *ret_conv = AcceptChannel_read(ser_ref);
17524         return (uint64_t)ret_conv;
17525 }
17526
17527 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
17528         LDKAnnouncementSignatures obj_conv;
17529         obj_conv.inner = (void*)(obj & (~1));
17530         obj_conv.is_owned = false;
17531         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
17532         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17533         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17534         CVec_u8Z_free(ret_var);
17535         return ret_arr;
17536 }
17537
17538 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
17539         LDKu8slice ser_ref;
17540         ser_ref.datalen = *((uint32_t*)ser);
17541         ser_ref.data = (int8_t*)(ser + 4);
17542         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17543         *ret_conv = AnnouncementSignatures_read(ser_ref);
17544         return (uint64_t)ret_conv;
17545 }
17546
17547 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
17548         LDKChannelReestablish obj_conv;
17549         obj_conv.inner = (void*)(obj & (~1));
17550         obj_conv.is_owned = false;
17551         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
17552         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17553         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17554         CVec_u8Z_free(ret_var);
17555         return ret_arr;
17556 }
17557
17558 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
17559         LDKu8slice ser_ref;
17560         ser_ref.datalen = *((uint32_t*)ser);
17561         ser_ref.data = (int8_t*)(ser + 4);
17562         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17563         *ret_conv = ChannelReestablish_read(ser_ref);
17564         return (uint64_t)ret_conv;
17565 }
17566
17567 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
17568         LDKClosingSigned obj_conv;
17569         obj_conv.inner = (void*)(obj & (~1));
17570         obj_conv.is_owned = false;
17571         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
17572         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17573         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17574         CVec_u8Z_free(ret_var);
17575         return ret_arr;
17576 }
17577
17578 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
17579         LDKu8slice ser_ref;
17580         ser_ref.datalen = *((uint32_t*)ser);
17581         ser_ref.data = (int8_t*)(ser + 4);
17582         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17583         *ret_conv = ClosingSigned_read(ser_ref);
17584         return (uint64_t)ret_conv;
17585 }
17586
17587 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
17588         LDKCommitmentSigned obj_conv;
17589         obj_conv.inner = (void*)(obj & (~1));
17590         obj_conv.is_owned = false;
17591         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
17592         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17593         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17594         CVec_u8Z_free(ret_var);
17595         return ret_arr;
17596 }
17597
17598 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
17599         LDKu8slice ser_ref;
17600         ser_ref.datalen = *((uint32_t*)ser);
17601         ser_ref.data = (int8_t*)(ser + 4);
17602         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17603         *ret_conv = CommitmentSigned_read(ser_ref);
17604         return (uint64_t)ret_conv;
17605 }
17606
17607 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
17608         LDKFundingCreated obj_conv;
17609         obj_conv.inner = (void*)(obj & (~1));
17610         obj_conv.is_owned = false;
17611         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
17612         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17613         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17614         CVec_u8Z_free(ret_var);
17615         return ret_arr;
17616 }
17617
17618 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
17619         LDKu8slice ser_ref;
17620         ser_ref.datalen = *((uint32_t*)ser);
17621         ser_ref.data = (int8_t*)(ser + 4);
17622         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17623         *ret_conv = FundingCreated_read(ser_ref);
17624         return (uint64_t)ret_conv;
17625 }
17626
17627 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
17628         LDKFundingSigned obj_conv;
17629         obj_conv.inner = (void*)(obj & (~1));
17630         obj_conv.is_owned = false;
17631         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
17632         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17633         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17634         CVec_u8Z_free(ret_var);
17635         return ret_arr;
17636 }
17637
17638 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
17639         LDKu8slice ser_ref;
17640         ser_ref.datalen = *((uint32_t*)ser);
17641         ser_ref.data = (int8_t*)(ser + 4);
17642         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17643         *ret_conv = FundingSigned_read(ser_ref);
17644         return (uint64_t)ret_conv;
17645 }
17646
17647 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
17648         LDKFundingLocked obj_conv;
17649         obj_conv.inner = (void*)(obj & (~1));
17650         obj_conv.is_owned = false;
17651         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
17652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17654         CVec_u8Z_free(ret_var);
17655         return ret_arr;
17656 }
17657
17658 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
17659         LDKu8slice ser_ref;
17660         ser_ref.datalen = *((uint32_t*)ser);
17661         ser_ref.data = (int8_t*)(ser + 4);
17662         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17663         *ret_conv = FundingLocked_read(ser_ref);
17664         return (uint64_t)ret_conv;
17665 }
17666
17667 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
17668         LDKInit obj_conv;
17669         obj_conv.inner = (void*)(obj & (~1));
17670         obj_conv.is_owned = false;
17671         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
17672         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17673         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17674         CVec_u8Z_free(ret_var);
17675         return ret_arr;
17676 }
17677
17678 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
17679         LDKu8slice ser_ref;
17680         ser_ref.datalen = *((uint32_t*)ser);
17681         ser_ref.data = (int8_t*)(ser + 4);
17682         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17683         *ret_conv = Init_read(ser_ref);
17684         return (uint64_t)ret_conv;
17685 }
17686
17687 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
17688         LDKOpenChannel obj_conv;
17689         obj_conv.inner = (void*)(obj & (~1));
17690         obj_conv.is_owned = false;
17691         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
17692         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17693         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17694         CVec_u8Z_free(ret_var);
17695         return ret_arr;
17696 }
17697
17698 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
17699         LDKu8slice ser_ref;
17700         ser_ref.datalen = *((uint32_t*)ser);
17701         ser_ref.data = (int8_t*)(ser + 4);
17702         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17703         *ret_conv = OpenChannel_read(ser_ref);
17704         return (uint64_t)ret_conv;
17705 }
17706
17707 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
17708         LDKRevokeAndACK obj_conv;
17709         obj_conv.inner = (void*)(obj & (~1));
17710         obj_conv.is_owned = false;
17711         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
17712         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17713         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17714         CVec_u8Z_free(ret_var);
17715         return ret_arr;
17716 }
17717
17718 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
17719         LDKu8slice ser_ref;
17720         ser_ref.datalen = *((uint32_t*)ser);
17721         ser_ref.data = (int8_t*)(ser + 4);
17722         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17723         *ret_conv = RevokeAndACK_read(ser_ref);
17724         return (uint64_t)ret_conv;
17725 }
17726
17727 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
17728         LDKShutdown obj_conv;
17729         obj_conv.inner = (void*)(obj & (~1));
17730         obj_conv.is_owned = false;
17731         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
17732         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17733         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17734         CVec_u8Z_free(ret_var);
17735         return ret_arr;
17736 }
17737
17738 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
17739         LDKu8slice ser_ref;
17740         ser_ref.datalen = *((uint32_t*)ser);
17741         ser_ref.data = (int8_t*)(ser + 4);
17742         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17743         *ret_conv = Shutdown_read(ser_ref);
17744         return (uint64_t)ret_conv;
17745 }
17746
17747 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
17748         LDKUpdateFailHTLC obj_conv;
17749         obj_conv.inner = (void*)(obj & (~1));
17750         obj_conv.is_owned = false;
17751         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
17752         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17753         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17754         CVec_u8Z_free(ret_var);
17755         return ret_arr;
17756 }
17757
17758 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
17759         LDKu8slice ser_ref;
17760         ser_ref.datalen = *((uint32_t*)ser);
17761         ser_ref.data = (int8_t*)(ser + 4);
17762         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17763         *ret_conv = UpdateFailHTLC_read(ser_ref);
17764         return (uint64_t)ret_conv;
17765 }
17766
17767 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
17768         LDKUpdateFailMalformedHTLC obj_conv;
17769         obj_conv.inner = (void*)(obj & (~1));
17770         obj_conv.is_owned = false;
17771         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
17772         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17773         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17774         CVec_u8Z_free(ret_var);
17775         return ret_arr;
17776 }
17777
17778 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
17779         LDKu8slice ser_ref;
17780         ser_ref.datalen = *((uint32_t*)ser);
17781         ser_ref.data = (int8_t*)(ser + 4);
17782         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
17783         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
17784         return (uint64_t)ret_conv;
17785 }
17786
17787 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
17788         LDKUpdateFee obj_conv;
17789         obj_conv.inner = (void*)(obj & (~1));
17790         obj_conv.is_owned = false;
17791         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
17792         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17793         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17794         CVec_u8Z_free(ret_var);
17795         return ret_arr;
17796 }
17797
17798 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
17799         LDKu8slice ser_ref;
17800         ser_ref.datalen = *((uint32_t*)ser);
17801         ser_ref.data = (int8_t*)(ser + 4);
17802         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
17803         *ret_conv = UpdateFee_read(ser_ref);
17804         return (uint64_t)ret_conv;
17805 }
17806
17807 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
17808         LDKUpdateFulfillHTLC obj_conv;
17809         obj_conv.inner = (void*)(obj & (~1));
17810         obj_conv.is_owned = false;
17811         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
17812         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17813         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17814         CVec_u8Z_free(ret_var);
17815         return ret_arr;
17816 }
17817
17818 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
17819         LDKu8slice ser_ref;
17820         ser_ref.datalen = *((uint32_t*)ser);
17821         ser_ref.data = (int8_t*)(ser + 4);
17822         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
17823         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
17824         return (uint64_t)ret_conv;
17825 }
17826
17827 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
17828         LDKUpdateAddHTLC obj_conv;
17829         obj_conv.inner = (void*)(obj & (~1));
17830         obj_conv.is_owned = false;
17831         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
17832         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17833         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17834         CVec_u8Z_free(ret_var);
17835         return ret_arr;
17836 }
17837
17838 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
17839         LDKu8slice ser_ref;
17840         ser_ref.datalen = *((uint32_t*)ser);
17841         ser_ref.data = (int8_t*)(ser + 4);
17842         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
17843         *ret_conv = UpdateAddHTLC_read(ser_ref);
17844         return (uint64_t)ret_conv;
17845 }
17846
17847 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
17848         LDKPing obj_conv;
17849         obj_conv.inner = (void*)(obj & (~1));
17850         obj_conv.is_owned = false;
17851         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
17852         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17853         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17854         CVec_u8Z_free(ret_var);
17855         return ret_arr;
17856 }
17857
17858 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
17859         LDKu8slice ser_ref;
17860         ser_ref.datalen = *((uint32_t*)ser);
17861         ser_ref.data = (int8_t*)(ser + 4);
17862         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
17863         *ret_conv = Ping_read(ser_ref);
17864         return (uint64_t)ret_conv;
17865 }
17866
17867 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
17868         LDKPong obj_conv;
17869         obj_conv.inner = (void*)(obj & (~1));
17870         obj_conv.is_owned = false;
17871         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
17872         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17873         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17874         CVec_u8Z_free(ret_var);
17875         return ret_arr;
17876 }
17877
17878 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
17879         LDKu8slice ser_ref;
17880         ser_ref.datalen = *((uint32_t*)ser);
17881         ser_ref.data = (int8_t*)(ser + 4);
17882         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
17883         *ret_conv = Pong_read(ser_ref);
17884         return (uint64_t)ret_conv;
17885 }
17886
17887 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
17888         LDKUnsignedChannelAnnouncement obj_conv;
17889         obj_conv.inner = (void*)(obj & (~1));
17890         obj_conv.is_owned = false;
17891         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
17892         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17893         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17894         CVec_u8Z_free(ret_var);
17895         return ret_arr;
17896 }
17897
17898 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
17899         LDKu8slice ser_ref;
17900         ser_ref.datalen = *((uint32_t*)ser);
17901         ser_ref.data = (int8_t*)(ser + 4);
17902         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
17903         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
17904         return (uint64_t)ret_conv;
17905 }
17906
17907 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
17908         LDKChannelAnnouncement obj_conv;
17909         obj_conv.inner = (void*)(obj & (~1));
17910         obj_conv.is_owned = false;
17911         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
17912         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17913         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17914         CVec_u8Z_free(ret_var);
17915         return ret_arr;
17916 }
17917
17918 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
17919         LDKu8slice ser_ref;
17920         ser_ref.datalen = *((uint32_t*)ser);
17921         ser_ref.data = (int8_t*)(ser + 4);
17922         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
17923         *ret_conv = ChannelAnnouncement_read(ser_ref);
17924         return (uint64_t)ret_conv;
17925 }
17926
17927 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
17928         LDKUnsignedChannelUpdate obj_conv;
17929         obj_conv.inner = (void*)(obj & (~1));
17930         obj_conv.is_owned = false;
17931         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
17932         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17933         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17934         CVec_u8Z_free(ret_var);
17935         return ret_arr;
17936 }
17937
17938 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
17939         LDKu8slice ser_ref;
17940         ser_ref.datalen = *((uint32_t*)ser);
17941         ser_ref.data = (int8_t*)(ser + 4);
17942         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
17943         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
17944         return (uint64_t)ret_conv;
17945 }
17946
17947 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
17948         LDKChannelUpdate obj_conv;
17949         obj_conv.inner = (void*)(obj & (~1));
17950         obj_conv.is_owned = false;
17951         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
17952         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17953         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17954         CVec_u8Z_free(ret_var);
17955         return ret_arr;
17956 }
17957
17958 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
17959         LDKu8slice ser_ref;
17960         ser_ref.datalen = *((uint32_t*)ser);
17961         ser_ref.data = (int8_t*)(ser + 4);
17962         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
17963         *ret_conv = ChannelUpdate_read(ser_ref);
17964         return (uint64_t)ret_conv;
17965 }
17966
17967 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
17968         LDKErrorMessage obj_conv;
17969         obj_conv.inner = (void*)(obj & (~1));
17970         obj_conv.is_owned = false;
17971         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
17972         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17973         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17974         CVec_u8Z_free(ret_var);
17975         return ret_arr;
17976 }
17977
17978 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
17979         LDKu8slice ser_ref;
17980         ser_ref.datalen = *((uint32_t*)ser);
17981         ser_ref.data = (int8_t*)(ser + 4);
17982         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
17983         *ret_conv = ErrorMessage_read(ser_ref);
17984         return (uint64_t)ret_conv;
17985 }
17986
17987 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
17988         LDKUnsignedNodeAnnouncement obj_conv;
17989         obj_conv.inner = (void*)(obj & (~1));
17990         obj_conv.is_owned = false;
17991         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
17992         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17993         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17994         CVec_u8Z_free(ret_var);
17995         return ret_arr;
17996 }
17997
17998 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
17999         LDKu8slice ser_ref;
18000         ser_ref.datalen = *((uint32_t*)ser);
18001         ser_ref.data = (int8_t*)(ser + 4);
18002         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18003         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
18004         return (uint64_t)ret_conv;
18005 }
18006
18007 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
18008         LDKNodeAnnouncement obj_conv;
18009         obj_conv.inner = (void*)(obj & (~1));
18010         obj_conv.is_owned = false;
18011         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
18012         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18013         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18014         CVec_u8Z_free(ret_var);
18015         return ret_arr;
18016 }
18017
18018 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
18019         LDKu8slice ser_ref;
18020         ser_ref.datalen = *((uint32_t*)ser);
18021         ser_ref.data = (int8_t*)(ser + 4);
18022         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18023         *ret_conv = NodeAnnouncement_read(ser_ref);
18024         return (uint64_t)ret_conv;
18025 }
18026
18027 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
18028         LDKu8slice ser_ref;
18029         ser_ref.datalen = *((uint32_t*)ser);
18030         ser_ref.data = (int8_t*)(ser + 4);
18031         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18032         *ret_conv = QueryShortChannelIds_read(ser_ref);
18033         return (uint64_t)ret_conv;
18034 }
18035
18036 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
18037         LDKQueryShortChannelIds obj_conv;
18038         obj_conv.inner = (void*)(obj & (~1));
18039         obj_conv.is_owned = false;
18040         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
18041         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18042         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18043         CVec_u8Z_free(ret_var);
18044         return ret_arr;
18045 }
18046
18047 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
18048         LDKu8slice ser_ref;
18049         ser_ref.datalen = *((uint32_t*)ser);
18050         ser_ref.data = (int8_t*)(ser + 4);
18051         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18052         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
18053         return (uint64_t)ret_conv;
18054 }
18055
18056 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
18057         LDKReplyShortChannelIdsEnd obj_conv;
18058         obj_conv.inner = (void*)(obj & (~1));
18059         obj_conv.is_owned = false;
18060         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
18061         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18062         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18063         CVec_u8Z_free(ret_var);
18064         return ret_arr;
18065 }
18066
18067 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
18068         LDKQueryChannelRange this_arg_conv;
18069         this_arg_conv.inner = (void*)(this_arg & (~1));
18070         this_arg_conv.is_owned = false;
18071         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
18072         return ret_val;
18073 }
18074
18075 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
18076         LDKu8slice ser_ref;
18077         ser_ref.datalen = *((uint32_t*)ser);
18078         ser_ref.data = (int8_t*)(ser + 4);
18079         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18080         *ret_conv = QueryChannelRange_read(ser_ref);
18081         return (uint64_t)ret_conv;
18082 }
18083
18084 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
18085         LDKQueryChannelRange obj_conv;
18086         obj_conv.inner = (void*)(obj & (~1));
18087         obj_conv.is_owned = false;
18088         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
18089         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18090         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18091         CVec_u8Z_free(ret_var);
18092         return ret_arr;
18093 }
18094
18095 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
18096         LDKu8slice ser_ref;
18097         ser_ref.datalen = *((uint32_t*)ser);
18098         ser_ref.data = (int8_t*)(ser + 4);
18099         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18100         *ret_conv = ReplyChannelRange_read(ser_ref);
18101         return (uint64_t)ret_conv;
18102 }
18103
18104 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
18105         LDKReplyChannelRange obj_conv;
18106         obj_conv.inner = (void*)(obj & (~1));
18107         obj_conv.is_owned = false;
18108         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
18109         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18110         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18111         CVec_u8Z_free(ret_var);
18112         return ret_arr;
18113 }
18114
18115 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
18116         LDKu8slice ser_ref;
18117         ser_ref.datalen = *((uint32_t*)ser);
18118         ser_ref.data = (int8_t*)(ser + 4);
18119         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18120         *ret_conv = GossipTimestampFilter_read(ser_ref);
18121         return (uint64_t)ret_conv;
18122 }
18123
18124 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
18125         LDKGossipTimestampFilter obj_conv;
18126         obj_conv.inner = (void*)(obj & (~1));
18127         obj_conv.is_owned = false;
18128         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
18129         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18130         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18131         CVec_u8Z_free(ret_var);
18132         return ret_arr;
18133 }
18134
18135 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
18136         LDKIgnoringMessageHandler this_obj_conv;
18137         this_obj_conv.inner = (void*)(this_obj & (~1));
18138         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18139         IgnoringMessageHandler_free(this_obj_conv);
18140 }
18141
18142 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
18143         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
18144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18146         uint64_t ret_ref = (uint64_t)ret_var.inner;
18147         if (ret_var.is_owned) {
18148                 ret_ref |= 1;
18149         }
18150         return ret_ref;
18151 }
18152
18153 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18154         LDKIgnoringMessageHandler this_arg_conv;
18155         this_arg_conv.inner = (void*)(this_arg & (~1));
18156         this_arg_conv.is_owned = false;
18157         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18158         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18159         return (uint64_t)ret;
18160 }
18161
18162 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18163         LDKIgnoringMessageHandler this_arg_conv;
18164         this_arg_conv.inner = (void*)(this_arg & (~1));
18165         this_arg_conv.is_owned = false;
18166         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18167         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
18168         return (uint64_t)ret;
18169 }
18170
18171 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
18172         LDKErroringMessageHandler this_obj_conv;
18173         this_obj_conv.inner = (void*)(this_obj & (~1));
18174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18175         ErroringMessageHandler_free(this_obj_conv);
18176 }
18177
18178 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
18179         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
18180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18182         uint64_t ret_ref = (uint64_t)ret_var.inner;
18183         if (ret_var.is_owned) {
18184                 ret_ref |= 1;
18185         }
18186         return ret_ref;
18187 }
18188
18189 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18190         LDKErroringMessageHandler this_arg_conv;
18191         this_arg_conv.inner = (void*)(this_arg & (~1));
18192         this_arg_conv.is_owned = false;
18193         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18194         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
18195         return (uint64_t)ret;
18196 }
18197
18198 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
18199         LDKErroringMessageHandler this_arg_conv;
18200         this_arg_conv.inner = (void*)(this_arg & (~1));
18201         this_arg_conv.is_owned = false;
18202         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
18203         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
18204         return (uint64_t)ret;
18205 }
18206
18207 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
18208         LDKMessageHandler this_obj_conv;
18209         this_obj_conv.inner = (void*)(this_obj & (~1));
18210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18211         MessageHandler_free(this_obj_conv);
18212 }
18213
18214 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
18215         LDKMessageHandler this_ptr_conv;
18216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18217         this_ptr_conv.is_owned = false;
18218         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
18219         return ret_ret;
18220 }
18221
18222 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
18223         LDKMessageHandler this_ptr_conv;
18224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18225         this_ptr_conv.is_owned = false;
18226         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
18227         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
18228 }
18229
18230 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
18231         LDKMessageHandler this_ptr_conv;
18232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18233         this_ptr_conv.is_owned = false;
18234         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
18235         return ret_ret;
18236 }
18237
18238 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
18239         LDKMessageHandler this_ptr_conv;
18240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18241         this_ptr_conv.is_owned = false;
18242         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
18243         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
18244 }
18245
18246 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
18247         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
18248         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
18249         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
18250         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18251         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18252         uint64_t ret_ref = (uint64_t)ret_var.inner;
18253         if (ret_var.is_owned) {
18254                 ret_ref |= 1;
18255         }
18256         return ret_ref;
18257 }
18258
18259 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
18260         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
18261         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
18262         *ret = SocketDescriptor_clone(orig_conv);
18263         return (uint64_t)ret;
18264 }
18265
18266 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
18267         if ((this_ptr & 1) != 0) return;
18268         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
18269         FREE((void*)this_ptr);
18270         SocketDescriptor_free(this_ptr_conv);
18271 }
18272
18273 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
18274         LDKPeerHandleError this_obj_conv;
18275         this_obj_conv.inner = (void*)(this_obj & (~1));
18276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18277         PeerHandleError_free(this_obj_conv);
18278 }
18279
18280 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
18281         LDKPeerHandleError this_ptr_conv;
18282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18283         this_ptr_conv.is_owned = false;
18284         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
18285         return ret_val;
18286 }
18287
18288 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
18289         LDKPeerHandleError this_ptr_conv;
18290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18291         this_ptr_conv.is_owned = false;
18292         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
18293 }
18294
18295 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
18296         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
18297         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18298         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18299         uint64_t ret_ref = (uint64_t)ret_var.inner;
18300         if (ret_var.is_owned) {
18301                 ret_ref |= 1;
18302         }
18303         return ret_ref;
18304 }
18305
18306 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
18307         LDKPeerHandleError orig_conv;
18308         orig_conv.inner = (void*)(orig & (~1));
18309         orig_conv.is_owned = false;
18310         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
18311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18313         uint64_t ret_ref = (uint64_t)ret_var.inner;
18314         if (ret_var.is_owned) {
18315                 ret_ref |= 1;
18316         }
18317         return ret_ref;
18318 }
18319
18320 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
18321         LDKPeerManager this_obj_conv;
18322         this_obj_conv.inner = (void*)(this_obj & (~1));
18323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18324         PeerManager_free(this_obj_conv);
18325 }
18326
18327 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) {
18328         LDKMessageHandler message_handler_conv;
18329         message_handler_conv.inner = (void*)(message_handler & (~1));
18330         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
18331         // Warning: we need a move here but no clone is available for LDKMessageHandler
18332         LDKSecretKey our_node_secret_ref;
18333         CHECK(*((uint32_t*)our_node_secret) == 32);
18334         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
18335         unsigned char ephemeral_random_data_arr[32];
18336         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
18337         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
18338         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
18339         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18340         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
18341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18343         uint64_t ret_ref = (uint64_t)ret_var.inner;
18344         if (ret_var.is_owned) {
18345                 ret_ref |= 1;
18346         }
18347         return ret_ref;
18348 }
18349
18350 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
18351         LDKPeerManager this_arg_conv;
18352         this_arg_conv.inner = (void*)(this_arg & (~1));
18353         this_arg_conv.is_owned = false;
18354         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
18355         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
18356         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
18357         for (size_t m = 0; m < ret_var.datalen; m++) {
18358                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18359                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
18360                 ret_arr_ptr[m] = ret_conv_12_arr;
18361         }
18362         FREE(ret_var.data);
18363         return ret_arr;
18364 }
18365
18366 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
18367         LDKPeerManager this_arg_conv;
18368         this_arg_conv.inner = (void*)(this_arg & (~1));
18369         this_arg_conv.is_owned = false;
18370         LDKPublicKey their_node_id_ref;
18371         CHECK(*((uint32_t*)their_node_id) == 33);
18372         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
18373         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18374         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18375         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
18376         return (uint64_t)ret_conv;
18377 }
18378
18379 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
18380         LDKPeerManager this_arg_conv;
18381         this_arg_conv.inner = (void*)(this_arg & (~1));
18382         this_arg_conv.is_owned = false;
18383         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18384         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18385         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
18386         return (uint64_t)ret_conv;
18387 }
18388
18389 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
18390         LDKPeerManager this_arg_conv;
18391         this_arg_conv.inner = (void*)(this_arg & (~1));
18392         this_arg_conv.is_owned = false;
18393         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18394         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18395         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
18396         return (uint64_t)ret_conv;
18397 }
18398
18399 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
18400         LDKPeerManager this_arg_conv;
18401         this_arg_conv.inner = (void*)(this_arg & (~1));
18402         this_arg_conv.is_owned = false;
18403         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
18404         LDKu8slice data_ref;
18405         data_ref.datalen = *((uint32_t*)data);
18406         data_ref.data = (int8_t*)(data + 4);
18407         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18408         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
18409         return (uint64_t)ret_conv;
18410 }
18411
18412 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
18413         LDKPeerManager this_arg_conv;
18414         this_arg_conv.inner = (void*)(this_arg & (~1));
18415         this_arg_conv.is_owned = false;
18416         PeerManager_process_events(&this_arg_conv);
18417 }
18418
18419 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
18420         LDKPeerManager this_arg_conv;
18421         this_arg_conv.inner = (void*)(this_arg & (~1));
18422         this_arg_conv.is_owned = false;
18423         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
18424         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
18425 }
18426
18427 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
18428         LDKPeerManager this_arg_conv;
18429         this_arg_conv.inner = (void*)(this_arg & (~1));
18430         this_arg_conv.is_owned = false;
18431         LDKPublicKey node_id_ref;
18432         CHECK(*((uint32_t*)node_id) == 33);
18433         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
18434         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
18435 }
18436
18437 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
18438         LDKPeerManager this_arg_conv;
18439         this_arg_conv.inner = (void*)(this_arg & (~1));
18440         this_arg_conv.is_owned = false;
18441         PeerManager_timer_tick_occurred(&this_arg_conv);
18442 }
18443
18444 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
18445         unsigned char commitment_seed_arr[32];
18446         CHECK(*((uint32_t*)commitment_seed) == 32);
18447         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
18448         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
18449         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18450         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
18451         return ret_arr;
18452 }
18453
18454 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
18455         LDKPublicKey per_commitment_point_ref;
18456         CHECK(*((uint32_t*)per_commitment_point) == 33);
18457         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18458         unsigned char base_secret_arr[32];
18459         CHECK(*((uint32_t*)base_secret) == 32);
18460         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
18461         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
18462         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18463         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
18464         return (uint64_t)ret_conv;
18465 }
18466
18467 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
18468         LDKPublicKey per_commitment_point_ref;
18469         CHECK(*((uint32_t*)per_commitment_point) == 33);
18470         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18471         LDKPublicKey base_point_ref;
18472         CHECK(*((uint32_t*)base_point) == 33);
18473         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
18474         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18475         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
18476         return (uint64_t)ret_conv;
18477 }
18478
18479 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
18480         unsigned char per_commitment_secret_arr[32];
18481         CHECK(*((uint32_t*)per_commitment_secret) == 32);
18482         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
18483         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
18484         unsigned char countersignatory_revocation_base_secret_arr[32];
18485         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
18486         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
18487         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
18488         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
18489         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
18490         return (uint64_t)ret_conv;
18491 }
18492
18493 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
18494         LDKPublicKey per_commitment_point_ref;
18495         CHECK(*((uint32_t*)per_commitment_point) == 33);
18496         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18497         LDKPublicKey countersignatory_revocation_base_point_ref;
18498         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
18499         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
18500         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
18501         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
18502         return (uint64_t)ret_conv;
18503 }
18504
18505 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
18506         LDKTxCreationKeys this_obj_conv;
18507         this_obj_conv.inner = (void*)(this_obj & (~1));
18508         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18509         TxCreationKeys_free(this_obj_conv);
18510 }
18511
18512 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
18513         LDKTxCreationKeys this_ptr_conv;
18514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18515         this_ptr_conv.is_owned = false;
18516         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18517         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18518         return ret_arr;
18519 }
18520
18521 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18522         LDKTxCreationKeys this_ptr_conv;
18523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18524         this_ptr_conv.is_owned = false;
18525         LDKPublicKey val_ref;
18526         CHECK(*((uint32_t*)val) == 33);
18527         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18528         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
18529 }
18530
18531 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
18532         LDKTxCreationKeys this_ptr_conv;
18533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18534         this_ptr_conv.is_owned = false;
18535         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18536         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
18537         return ret_arr;
18538 }
18539
18540 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
18541         LDKTxCreationKeys this_ptr_conv;
18542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18543         this_ptr_conv.is_owned = false;
18544         LDKPublicKey val_ref;
18545         CHECK(*((uint32_t*)val) == 33);
18546         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18547         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
18548 }
18549
18550 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
18551         LDKTxCreationKeys this_ptr_conv;
18552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18553         this_ptr_conv.is_owned = false;
18554         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18555         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
18556         return ret_arr;
18557 }
18558
18559 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
18560         LDKTxCreationKeys this_ptr_conv;
18561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18562         this_ptr_conv.is_owned = false;
18563         LDKPublicKey val_ref;
18564         CHECK(*((uint32_t*)val) == 33);
18565         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18566         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
18567 }
18568
18569 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
18570         LDKTxCreationKeys this_ptr_conv;
18571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18572         this_ptr_conv.is_owned = false;
18573         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18574         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
18575         return ret_arr;
18576 }
18577
18578 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
18579         LDKTxCreationKeys this_ptr_conv;
18580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18581         this_ptr_conv.is_owned = false;
18582         LDKPublicKey val_ref;
18583         CHECK(*((uint32_t*)val) == 33);
18584         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18585         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
18586 }
18587
18588 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
18589         LDKTxCreationKeys this_ptr_conv;
18590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18591         this_ptr_conv.is_owned = false;
18592         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18593         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
18594         return ret_arr;
18595 }
18596
18597 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
18598         LDKTxCreationKeys this_ptr_conv;
18599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18600         this_ptr_conv.is_owned = false;
18601         LDKPublicKey val_ref;
18602         CHECK(*((uint32_t*)val) == 33);
18603         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18604         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
18605 }
18606
18607 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) {
18608         LDKPublicKey per_commitment_point_arg_ref;
18609         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
18610         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
18611         LDKPublicKey revocation_key_arg_ref;
18612         CHECK(*((uint32_t*)revocation_key_arg) == 33);
18613         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
18614         LDKPublicKey broadcaster_htlc_key_arg_ref;
18615         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
18616         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
18617         LDKPublicKey countersignatory_htlc_key_arg_ref;
18618         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
18619         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
18620         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
18621         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
18622         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
18623         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);
18624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18626         uint64_t ret_ref = (uint64_t)ret_var.inner;
18627         if (ret_var.is_owned) {
18628                 ret_ref |= 1;
18629         }
18630         return ret_ref;
18631 }
18632
18633 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
18634         LDKTxCreationKeys orig_conv;
18635         orig_conv.inner = (void*)(orig & (~1));
18636         orig_conv.is_owned = false;
18637         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
18638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18640         uint64_t ret_ref = (uint64_t)ret_var.inner;
18641         if (ret_var.is_owned) {
18642                 ret_ref |= 1;
18643         }
18644         return ret_ref;
18645 }
18646
18647 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
18648         LDKTxCreationKeys obj_conv;
18649         obj_conv.inner = (void*)(obj & (~1));
18650         obj_conv.is_owned = false;
18651         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
18652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18654         CVec_u8Z_free(ret_var);
18655         return ret_arr;
18656 }
18657
18658 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
18659         LDKu8slice ser_ref;
18660         ser_ref.datalen = *((uint32_t*)ser);
18661         ser_ref.data = (int8_t*)(ser + 4);
18662         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
18663         *ret_conv = TxCreationKeys_read(ser_ref);
18664         return (uint64_t)ret_conv;
18665 }
18666
18667 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
18668         LDKChannelPublicKeys this_obj_conv;
18669         this_obj_conv.inner = (void*)(this_obj & (~1));
18670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18671         ChannelPublicKeys_free(this_obj_conv);
18672 }
18673
18674 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
18675         LDKChannelPublicKeys this_ptr_conv;
18676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18677         this_ptr_conv.is_owned = false;
18678         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18679         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
18680         return ret_arr;
18681 }
18682
18683 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
18684         LDKChannelPublicKeys this_ptr_conv;
18685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18686         this_ptr_conv.is_owned = false;
18687         LDKPublicKey val_ref;
18688         CHECK(*((uint32_t*)val) == 33);
18689         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18690         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
18691 }
18692
18693 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
18694         LDKChannelPublicKeys this_ptr_conv;
18695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18696         this_ptr_conv.is_owned = false;
18697         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18698         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
18699         return ret_arr;
18700 }
18701
18702 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
18703         LDKChannelPublicKeys this_ptr_conv;
18704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18705         this_ptr_conv.is_owned = false;
18706         LDKPublicKey val_ref;
18707         CHECK(*((uint32_t*)val) == 33);
18708         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18709         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
18710 }
18711
18712 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
18713         LDKChannelPublicKeys this_ptr_conv;
18714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18715         this_ptr_conv.is_owned = false;
18716         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18717         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
18718         return ret_arr;
18719 }
18720
18721 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
18722         LDKChannelPublicKeys this_ptr_conv;
18723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18724         this_ptr_conv.is_owned = false;
18725         LDKPublicKey val_ref;
18726         CHECK(*((uint32_t*)val) == 33);
18727         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18728         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
18729 }
18730
18731 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
18732         LDKChannelPublicKeys this_ptr_conv;
18733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18734         this_ptr_conv.is_owned = false;
18735         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18736         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
18737         return ret_arr;
18738 }
18739
18740 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
18741         LDKChannelPublicKeys this_ptr_conv;
18742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18743         this_ptr_conv.is_owned = false;
18744         LDKPublicKey val_ref;
18745         CHECK(*((uint32_t*)val) == 33);
18746         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18747         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18748 }
18749
18750 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
18751         LDKChannelPublicKeys this_ptr_conv;
18752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18753         this_ptr_conv.is_owned = false;
18754         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18755         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
18756         return ret_arr;
18757 }
18758
18759 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
18760         LDKChannelPublicKeys this_ptr_conv;
18761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18762         this_ptr_conv.is_owned = false;
18763         LDKPublicKey val_ref;
18764         CHECK(*((uint32_t*)val) == 33);
18765         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18766         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
18767 }
18768
18769 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) {
18770         LDKPublicKey funding_pubkey_arg_ref;
18771         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
18772         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
18773         LDKPublicKey revocation_basepoint_arg_ref;
18774         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
18775         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
18776         LDKPublicKey payment_point_arg_ref;
18777         CHECK(*((uint32_t*)payment_point_arg) == 33);
18778         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
18779         LDKPublicKey delayed_payment_basepoint_arg_ref;
18780         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
18781         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
18782         LDKPublicKey htlc_basepoint_arg_ref;
18783         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
18784         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
18785         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);
18786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18788         uint64_t ret_ref = (uint64_t)ret_var.inner;
18789         if (ret_var.is_owned) {
18790                 ret_ref |= 1;
18791         }
18792         return ret_ref;
18793 }
18794
18795 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
18796         LDKChannelPublicKeys orig_conv;
18797         orig_conv.inner = (void*)(orig & (~1));
18798         orig_conv.is_owned = false;
18799         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
18800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18802         uint64_t ret_ref = (uint64_t)ret_var.inner;
18803         if (ret_var.is_owned) {
18804                 ret_ref |= 1;
18805         }
18806         return ret_ref;
18807 }
18808
18809 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
18810         LDKChannelPublicKeys obj_conv;
18811         obj_conv.inner = (void*)(obj & (~1));
18812         obj_conv.is_owned = false;
18813         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
18814         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18815         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18816         CVec_u8Z_free(ret_var);
18817         return ret_arr;
18818 }
18819
18820 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
18821         LDKu8slice ser_ref;
18822         ser_ref.datalen = *((uint32_t*)ser);
18823         ser_ref.data = (int8_t*)(ser + 4);
18824         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
18825         *ret_conv = ChannelPublicKeys_read(ser_ref);
18826         return (uint64_t)ret_conv;
18827 }
18828
18829 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) {
18830         LDKPublicKey per_commitment_point_ref;
18831         CHECK(*((uint32_t*)per_commitment_point) == 33);
18832         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18833         LDKPublicKey broadcaster_delayed_payment_base_ref;
18834         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
18835         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
18836         LDKPublicKey broadcaster_htlc_base_ref;
18837         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
18838         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
18839         LDKPublicKey countersignatory_revocation_base_ref;
18840         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
18841         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
18842         LDKPublicKey countersignatory_htlc_base_ref;
18843         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
18844         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
18845         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18846         *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);
18847         return (uint64_t)ret_conv;
18848 }
18849
18850 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
18851         LDKPublicKey per_commitment_point_ref;
18852         CHECK(*((uint32_t*)per_commitment_point) == 33);
18853         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
18854         LDKChannelPublicKeys broadcaster_keys_conv;
18855         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
18856         broadcaster_keys_conv.is_owned = false;
18857         LDKChannelPublicKeys countersignatory_keys_conv;
18858         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
18859         countersignatory_keys_conv.is_owned = false;
18860         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
18861         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
18862         return (uint64_t)ret_conv;
18863 }
18864
18865 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
18866         LDKPublicKey revocation_key_ref;
18867         CHECK(*((uint32_t*)revocation_key) == 33);
18868         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
18869         LDKPublicKey broadcaster_delayed_payment_key_ref;
18870         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
18871         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
18872         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
18873         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18874         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18875         CVec_u8Z_free(ret_var);
18876         return ret_arr;
18877 }
18878
18879 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
18880         LDKHTLCOutputInCommitment this_obj_conv;
18881         this_obj_conv.inner = (void*)(this_obj & (~1));
18882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18883         HTLCOutputInCommitment_free(this_obj_conv);
18884 }
18885
18886 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
18887         LDKHTLCOutputInCommitment this_ptr_conv;
18888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18889         this_ptr_conv.is_owned = false;
18890         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
18891         return ret_val;
18892 }
18893
18894 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
18895         LDKHTLCOutputInCommitment this_ptr_conv;
18896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18897         this_ptr_conv.is_owned = false;
18898         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
18899 }
18900
18901 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
18902         LDKHTLCOutputInCommitment this_ptr_conv;
18903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18904         this_ptr_conv.is_owned = false;
18905         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
18906         return ret_val;
18907 }
18908
18909 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
18910         LDKHTLCOutputInCommitment this_ptr_conv;
18911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18912         this_ptr_conv.is_owned = false;
18913         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
18914 }
18915
18916 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
18917         LDKHTLCOutputInCommitment this_ptr_conv;
18918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18919         this_ptr_conv.is_owned = false;
18920         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
18921         return ret_val;
18922 }
18923
18924 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
18925         LDKHTLCOutputInCommitment this_ptr_conv;
18926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18927         this_ptr_conv.is_owned = false;
18928         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
18929 }
18930
18931 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
18932         LDKHTLCOutputInCommitment this_ptr_conv;
18933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18934         this_ptr_conv.is_owned = false;
18935         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18936         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
18937         return ret_arr;
18938 }
18939
18940 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
18941         LDKHTLCOutputInCommitment this_ptr_conv;
18942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18943         this_ptr_conv.is_owned = false;
18944         LDKThirtyTwoBytes val_ref;
18945         CHECK(*((uint32_t*)val) == 32);
18946         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18947         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
18948 }
18949
18950 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
18951         LDKHTLCOutputInCommitment this_ptr_conv;
18952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18953         this_ptr_conv.is_owned = false;
18954         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
18955         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
18956         uint64_t ret_ref = (uint64_t)ret_copy;
18957         return ret_ref;
18958 }
18959
18960 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
18961         LDKHTLCOutputInCommitment this_ptr_conv;
18962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18963         this_ptr_conv.is_owned = false;
18964         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
18965         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
18966 }
18967
18968 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) {
18969         LDKThirtyTwoBytes payment_hash_arg_ref;
18970         CHECK(*((uint32_t*)payment_hash_arg) == 32);
18971         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
18972         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
18973         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
18974         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18975         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18976         uint64_t ret_ref = (uint64_t)ret_var.inner;
18977         if (ret_var.is_owned) {
18978                 ret_ref |= 1;
18979         }
18980         return ret_ref;
18981 }
18982
18983 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
18984         LDKHTLCOutputInCommitment orig_conv;
18985         orig_conv.inner = (void*)(orig & (~1));
18986         orig_conv.is_owned = false;
18987         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
18988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18990         uint64_t ret_ref = (uint64_t)ret_var.inner;
18991         if (ret_var.is_owned) {
18992                 ret_ref |= 1;
18993         }
18994         return ret_ref;
18995 }
18996
18997 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
18998         LDKHTLCOutputInCommitment obj_conv;
18999         obj_conv.inner = (void*)(obj & (~1));
19000         obj_conv.is_owned = false;
19001         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
19002         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19003         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19004         CVec_u8Z_free(ret_var);
19005         return ret_arr;
19006 }
19007
19008 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
19009         LDKu8slice ser_ref;
19010         ser_ref.datalen = *((uint32_t*)ser);
19011         ser_ref.data = (int8_t*)(ser + 4);
19012         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
19013         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
19014         return (uint64_t)ret_conv;
19015 }
19016
19017 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
19018         LDKHTLCOutputInCommitment htlc_conv;
19019         htlc_conv.inner = (void*)(htlc & (~1));
19020         htlc_conv.is_owned = false;
19021         LDKTxCreationKeys keys_conv;
19022         keys_conv.inner = (void*)(keys & (~1));
19023         keys_conv.is_owned = false;
19024         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
19025         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19026         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19027         CVec_u8Z_free(ret_var);
19028         return ret_arr;
19029 }
19030
19031 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
19032         LDKPublicKey broadcaster_ref;
19033         CHECK(*((uint32_t*)broadcaster) == 33);
19034         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
19035         LDKPublicKey countersignatory_ref;
19036         CHECK(*((uint32_t*)countersignatory) == 33);
19037         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
19038         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
19039         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19040         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19041         CVec_u8Z_free(ret_var);
19042         return ret_arr;
19043 }
19044
19045 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) {
19046         unsigned char commitment_txid_arr[32];
19047         CHECK(*((uint32_t*)commitment_txid) == 32);
19048         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
19049         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
19050         LDKHTLCOutputInCommitment htlc_conv;
19051         htlc_conv.inner = (void*)(htlc & (~1));
19052         htlc_conv.is_owned = false;
19053         LDKPublicKey broadcaster_delayed_payment_key_ref;
19054         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
19055         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
19056         LDKPublicKey revocation_key_ref;
19057         CHECK(*((uint32_t*)revocation_key) == 33);
19058         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
19059         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
19060         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19061         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19062         Transaction_free(ret_var);
19063         return ret_arr;
19064 }
19065
19066 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
19067         LDKChannelTransactionParameters this_obj_conv;
19068         this_obj_conv.inner = (void*)(this_obj & (~1));
19069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19070         ChannelTransactionParameters_free(this_obj_conv);
19071 }
19072
19073 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
19074         LDKChannelTransactionParameters this_ptr_conv;
19075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19076         this_ptr_conv.is_owned = false;
19077         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
19078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19080         uint64_t ret_ref = (uint64_t)ret_var.inner;
19081         if (ret_var.is_owned) {
19082                 ret_ref |= 1;
19083         }
19084         return ret_ref;
19085 }
19086
19087 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
19088         LDKChannelTransactionParameters this_ptr_conv;
19089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19090         this_ptr_conv.is_owned = false;
19091         LDKChannelPublicKeys val_conv;
19092         val_conv.inner = (void*)(val & (~1));
19093         val_conv.is_owned = (val & 1) || (val == 0);
19094         val_conv = ChannelPublicKeys_clone(&val_conv);
19095         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
19096 }
19097
19098 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
19099         LDKChannelTransactionParameters this_ptr_conv;
19100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19101         this_ptr_conv.is_owned = false;
19102         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
19103         return ret_val;
19104 }
19105
19106 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19107         LDKChannelTransactionParameters this_ptr_conv;
19108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19109         this_ptr_conv.is_owned = false;
19110         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
19111 }
19112
19113 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
19114         LDKChannelTransactionParameters this_ptr_conv;
19115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19116         this_ptr_conv.is_owned = false;
19117         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
19118         return ret_val;
19119 }
19120
19121 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
19122         LDKChannelTransactionParameters this_ptr_conv;
19123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19124         this_ptr_conv.is_owned = false;
19125         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
19126 }
19127
19128 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
19129         LDKChannelTransactionParameters this_ptr_conv;
19130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19131         this_ptr_conv.is_owned = false;
19132         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
19133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19135         uint64_t ret_ref = (uint64_t)ret_var.inner;
19136         if (ret_var.is_owned) {
19137                 ret_ref |= 1;
19138         }
19139         return ret_ref;
19140 }
19141
19142 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
19143         LDKChannelTransactionParameters this_ptr_conv;
19144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19145         this_ptr_conv.is_owned = false;
19146         LDKCounterpartyChannelTransactionParameters val_conv;
19147         val_conv.inner = (void*)(val & (~1));
19148         val_conv.is_owned = (val & 1) || (val == 0);
19149         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
19150         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
19151 }
19152
19153 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
19154         LDKChannelTransactionParameters this_ptr_conv;
19155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19156         this_ptr_conv.is_owned = false;
19157         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
19158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19160         uint64_t ret_ref = (uint64_t)ret_var.inner;
19161         if (ret_var.is_owned) {
19162                 ret_ref |= 1;
19163         }
19164         return ret_ref;
19165 }
19166
19167 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
19168         LDKChannelTransactionParameters this_ptr_conv;
19169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19170         this_ptr_conv.is_owned = false;
19171         LDKOutPoint val_conv;
19172         val_conv.inner = (void*)(val & (~1));
19173         val_conv.is_owned = (val & 1) || (val == 0);
19174         val_conv = OutPoint_clone(&val_conv);
19175         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
19176 }
19177
19178 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) {
19179         LDKChannelPublicKeys holder_pubkeys_arg_conv;
19180         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
19181         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
19182         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
19183         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
19184         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
19185         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
19186         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
19187         LDKOutPoint funding_outpoint_arg_conv;
19188         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
19189         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
19190         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
19191         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);
19192         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19193         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19194         uint64_t ret_ref = (uint64_t)ret_var.inner;
19195         if (ret_var.is_owned) {
19196                 ret_ref |= 1;
19197         }
19198         return ret_ref;
19199 }
19200
19201 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
19202         LDKChannelTransactionParameters orig_conv;
19203         orig_conv.inner = (void*)(orig & (~1));
19204         orig_conv.is_owned = false;
19205         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
19206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19208         uint64_t ret_ref = (uint64_t)ret_var.inner;
19209         if (ret_var.is_owned) {
19210                 ret_ref |= 1;
19211         }
19212         return ret_ref;
19213 }
19214
19215 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
19216         LDKCounterpartyChannelTransactionParameters this_obj_conv;
19217         this_obj_conv.inner = (void*)(this_obj & (~1));
19218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19219         CounterpartyChannelTransactionParameters_free(this_obj_conv);
19220 }
19221
19222 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
19223         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19225         this_ptr_conv.is_owned = false;
19226         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
19227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19229         uint64_t ret_ref = (uint64_t)ret_var.inner;
19230         if (ret_var.is_owned) {
19231                 ret_ref |= 1;
19232         }
19233         return ret_ref;
19234 }
19235
19236 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
19237         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19239         this_ptr_conv.is_owned = false;
19240         LDKChannelPublicKeys val_conv;
19241         val_conv.inner = (void*)(val & (~1));
19242         val_conv.is_owned = (val & 1) || (val == 0);
19243         val_conv = ChannelPublicKeys_clone(&val_conv);
19244         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
19245 }
19246
19247 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
19248         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19250         this_ptr_conv.is_owned = false;
19251         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
19252         return ret_val;
19253 }
19254
19255 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
19256         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
19257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19258         this_ptr_conv.is_owned = false;
19259         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
19260 }
19261
19262 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
19263         LDKChannelPublicKeys pubkeys_arg_conv;
19264         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
19265         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
19266         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
19267         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
19268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19270         uint64_t ret_ref = (uint64_t)ret_var.inner;
19271         if (ret_var.is_owned) {
19272                 ret_ref |= 1;
19273         }
19274         return ret_ref;
19275 }
19276
19277 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
19278         LDKCounterpartyChannelTransactionParameters orig_conv;
19279         orig_conv.inner = (void*)(orig & (~1));
19280         orig_conv.is_owned = false;
19281         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
19282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19284         uint64_t ret_ref = (uint64_t)ret_var.inner;
19285         if (ret_var.is_owned) {
19286                 ret_ref |= 1;
19287         }
19288         return ret_ref;
19289 }
19290
19291 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
19292         LDKChannelTransactionParameters this_arg_conv;
19293         this_arg_conv.inner = (void*)(this_arg & (~1));
19294         this_arg_conv.is_owned = false;
19295         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
19296         return ret_val;
19297 }
19298
19299 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
19300         LDKChannelTransactionParameters this_arg_conv;
19301         this_arg_conv.inner = (void*)(this_arg & (~1));
19302         this_arg_conv.is_owned = false;
19303         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
19304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19306         uint64_t ret_ref = (uint64_t)ret_var.inner;
19307         if (ret_var.is_owned) {
19308                 ret_ref |= 1;
19309         }
19310         return ret_ref;
19311 }
19312
19313 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
19314         LDKChannelTransactionParameters this_arg_conv;
19315         this_arg_conv.inner = (void*)(this_arg & (~1));
19316         this_arg_conv.is_owned = false;
19317         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
19318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19320         uint64_t ret_ref = (uint64_t)ret_var.inner;
19321         if (ret_var.is_owned) {
19322                 ret_ref |= 1;
19323         }
19324         return ret_ref;
19325 }
19326
19327 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
19328         LDKCounterpartyChannelTransactionParameters obj_conv;
19329         obj_conv.inner = (void*)(obj & (~1));
19330         obj_conv.is_owned = false;
19331         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
19332         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19333         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19334         CVec_u8Z_free(ret_var);
19335         return ret_arr;
19336 }
19337
19338 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
19339         LDKu8slice ser_ref;
19340         ser_ref.datalen = *((uint32_t*)ser);
19341         ser_ref.data = (int8_t*)(ser + 4);
19342         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
19343         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
19344         return (uint64_t)ret_conv;
19345 }
19346
19347 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
19348         LDKChannelTransactionParameters obj_conv;
19349         obj_conv.inner = (void*)(obj & (~1));
19350         obj_conv.is_owned = false;
19351         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
19352         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19353         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19354         CVec_u8Z_free(ret_var);
19355         return ret_arr;
19356 }
19357
19358 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
19359         LDKu8slice ser_ref;
19360         ser_ref.datalen = *((uint32_t*)ser);
19361         ser_ref.data = (int8_t*)(ser + 4);
19362         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
19363         *ret_conv = ChannelTransactionParameters_read(ser_ref);
19364         return (uint64_t)ret_conv;
19365 }
19366
19367 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
19368         LDKDirectedChannelTransactionParameters this_obj_conv;
19369         this_obj_conv.inner = (void*)(this_obj & (~1));
19370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19371         DirectedChannelTransactionParameters_free(this_obj_conv);
19372 }
19373
19374 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
19375         LDKDirectedChannelTransactionParameters this_arg_conv;
19376         this_arg_conv.inner = (void*)(this_arg & (~1));
19377         this_arg_conv.is_owned = false;
19378         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
19379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19381         uint64_t ret_ref = (uint64_t)ret_var.inner;
19382         if (ret_var.is_owned) {
19383                 ret_ref |= 1;
19384         }
19385         return ret_ref;
19386 }
19387
19388 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
19389         LDKDirectedChannelTransactionParameters this_arg_conv;
19390         this_arg_conv.inner = (void*)(this_arg & (~1));
19391         this_arg_conv.is_owned = false;
19392         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
19393         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19394         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19395         uint64_t ret_ref = (uint64_t)ret_var.inner;
19396         if (ret_var.is_owned) {
19397                 ret_ref |= 1;
19398         }
19399         return ret_ref;
19400 }
19401
19402 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
19403         LDKDirectedChannelTransactionParameters this_arg_conv;
19404         this_arg_conv.inner = (void*)(this_arg & (~1));
19405         this_arg_conv.is_owned = false;
19406         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
19407         return ret_val;
19408 }
19409
19410 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
19411         LDKDirectedChannelTransactionParameters this_arg_conv;
19412         this_arg_conv.inner = (void*)(this_arg & (~1));
19413         this_arg_conv.is_owned = false;
19414         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
19415         return ret_val;
19416 }
19417
19418 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
19419         LDKDirectedChannelTransactionParameters this_arg_conv;
19420         this_arg_conv.inner = (void*)(this_arg & (~1));
19421         this_arg_conv.is_owned = false;
19422         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
19423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19425         uint64_t ret_ref = (uint64_t)ret_var.inner;
19426         if (ret_var.is_owned) {
19427                 ret_ref |= 1;
19428         }
19429         return ret_ref;
19430 }
19431
19432 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
19433         LDKHolderCommitmentTransaction this_obj_conv;
19434         this_obj_conv.inner = (void*)(this_obj & (~1));
19435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19436         HolderCommitmentTransaction_free(this_obj_conv);
19437 }
19438
19439 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
19440         LDKHolderCommitmentTransaction this_ptr_conv;
19441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19442         this_ptr_conv.is_owned = false;
19443         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19444         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
19445         return ret_arr;
19446 }
19447
19448 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
19449         LDKHolderCommitmentTransaction this_ptr_conv;
19450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19451         this_ptr_conv.is_owned = false;
19452         LDKSignature val_ref;
19453         CHECK(*((uint32_t*)val) == 64);
19454         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19455         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
19456 }
19457
19458 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
19459         LDKHolderCommitmentTransaction this_ptr_conv;
19460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19461         this_ptr_conv.is_owned = false;
19462         LDKCVec_SignatureZ val_constr;
19463         val_constr.datalen = *((uint32_t*)val);
19464         if (val_constr.datalen > 0)
19465                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19466         else
19467                 val_constr.data = NULL;
19468         int8_tArray* val_vals = (int8_tArray*)(val + 4);
19469         for (size_t m = 0; m < val_constr.datalen; m++) {
19470                 int8_tArray val_conv_12 = val_vals[m];
19471                 LDKSignature val_conv_12_ref;
19472                 CHECK(*((uint32_t*)val_conv_12) == 64);
19473                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
19474                 val_constr.data[m] = val_conv_12_ref;
19475         }
19476         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
19477 }
19478
19479 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
19480         LDKHolderCommitmentTransaction orig_conv;
19481         orig_conv.inner = (void*)(orig & (~1));
19482         orig_conv.is_owned = false;
19483         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
19484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19486         uint64_t ret_ref = (uint64_t)ret_var.inner;
19487         if (ret_var.is_owned) {
19488                 ret_ref |= 1;
19489         }
19490         return ret_ref;
19491 }
19492
19493 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
19494         LDKHolderCommitmentTransaction obj_conv;
19495         obj_conv.inner = (void*)(obj & (~1));
19496         obj_conv.is_owned = false;
19497         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
19498         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19499         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19500         CVec_u8Z_free(ret_var);
19501         return ret_arr;
19502 }
19503
19504 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
19505         LDKu8slice ser_ref;
19506         ser_ref.datalen = *((uint32_t*)ser);
19507         ser_ref.data = (int8_t*)(ser + 4);
19508         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
19509         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
19510         return (uint64_t)ret_conv;
19511 }
19512
19513 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) {
19514         LDKCommitmentTransaction commitment_tx_conv;
19515         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
19516         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
19517         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
19518         LDKSignature counterparty_sig_ref;
19519         CHECK(*((uint32_t*)counterparty_sig) == 64);
19520         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
19521         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
19522         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
19523         if (counterparty_htlc_sigs_constr.datalen > 0)
19524                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19525         else
19526                 counterparty_htlc_sigs_constr.data = NULL;
19527         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
19528         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
19529                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
19530                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
19531                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
19532                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
19533                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
19534         }
19535         LDKPublicKey holder_funding_key_ref;
19536         CHECK(*((uint32_t*)holder_funding_key) == 33);
19537         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
19538         LDKPublicKey counterparty_funding_key_ref;
19539         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
19540         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
19541         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
19542         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19543         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19544         uint64_t ret_ref = (uint64_t)ret_var.inner;
19545         if (ret_var.is_owned) {
19546                 ret_ref |= 1;
19547         }
19548         return ret_ref;
19549 }
19550
19551 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
19552         LDKBuiltCommitmentTransaction this_obj_conv;
19553         this_obj_conv.inner = (void*)(this_obj & (~1));
19554         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19555         BuiltCommitmentTransaction_free(this_obj_conv);
19556 }
19557
19558 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
19559         LDKBuiltCommitmentTransaction this_ptr_conv;
19560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19561         this_ptr_conv.is_owned = false;
19562         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
19563         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19564         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19565         Transaction_free(ret_var);
19566         return ret_arr;
19567 }
19568
19569 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
19570         LDKBuiltCommitmentTransaction this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         LDKTransaction val_ref;
19574         val_ref.datalen = *((uint32_t*)val);
19575         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
19576         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
19577         val_ref.data_is_owned = true;
19578         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
19579 }
19580
19581 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
19582         LDKBuiltCommitmentTransaction this_ptr_conv;
19583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19584         this_ptr_conv.is_owned = false;
19585         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19586         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
19587         return ret_arr;
19588 }
19589
19590 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
19591         LDKBuiltCommitmentTransaction this_ptr_conv;
19592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19593         this_ptr_conv.is_owned = false;
19594         LDKThirtyTwoBytes val_ref;
19595         CHECK(*((uint32_t*)val) == 32);
19596         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19597         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
19598 }
19599
19600 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
19601         LDKTransaction transaction_arg_ref;
19602         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
19603         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
19604         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
19605         transaction_arg_ref.data_is_owned = true;
19606         LDKThirtyTwoBytes txid_arg_ref;
19607         CHECK(*((uint32_t*)txid_arg) == 32);
19608         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19609         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
19610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19612         uint64_t ret_ref = (uint64_t)ret_var.inner;
19613         if (ret_var.is_owned) {
19614                 ret_ref |= 1;
19615         }
19616         return ret_ref;
19617 }
19618
19619 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
19620         LDKBuiltCommitmentTransaction orig_conv;
19621         orig_conv.inner = (void*)(orig & (~1));
19622         orig_conv.is_owned = false;
19623         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
19624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19626         uint64_t ret_ref = (uint64_t)ret_var.inner;
19627         if (ret_var.is_owned) {
19628                 ret_ref |= 1;
19629         }
19630         return ret_ref;
19631 }
19632
19633 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
19634         LDKBuiltCommitmentTransaction obj_conv;
19635         obj_conv.inner = (void*)(obj & (~1));
19636         obj_conv.is_owned = false;
19637         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
19638         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19639         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19640         CVec_u8Z_free(ret_var);
19641         return ret_arr;
19642 }
19643
19644 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
19645         LDKu8slice ser_ref;
19646         ser_ref.datalen = *((uint32_t*)ser);
19647         ser_ref.data = (int8_t*)(ser + 4);
19648         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
19649         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
19650         return (uint64_t)ret_conv;
19651 }
19652
19653 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
19654         LDKBuiltCommitmentTransaction this_arg_conv;
19655         this_arg_conv.inner = (void*)(this_arg & (~1));
19656         this_arg_conv.is_owned = false;
19657         LDKu8slice funding_redeemscript_ref;
19658         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19659         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19660         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19661         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
19662         return ret_arr;
19663 }
19664
19665 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) {
19666         LDKBuiltCommitmentTransaction this_arg_conv;
19667         this_arg_conv.inner = (void*)(this_arg & (~1));
19668         this_arg_conv.is_owned = false;
19669         unsigned char funding_key_arr[32];
19670         CHECK(*((uint32_t*)funding_key) == 32);
19671         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
19672         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
19673         LDKu8slice funding_redeemscript_ref;
19674         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
19675         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
19676         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19677         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
19678         return ret_arr;
19679 }
19680
19681 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
19682         LDKCommitmentTransaction this_obj_conv;
19683         this_obj_conv.inner = (void*)(this_obj & (~1));
19684         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19685         CommitmentTransaction_free(this_obj_conv);
19686 }
19687
19688 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
19689         LDKCommitmentTransaction orig_conv;
19690         orig_conv.inner = (void*)(orig & (~1));
19691         orig_conv.is_owned = false;
19692         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
19693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19695         uint64_t ret_ref = (uint64_t)ret_var.inner;
19696         if (ret_var.is_owned) {
19697                 ret_ref |= 1;
19698         }
19699         return ret_ref;
19700 }
19701
19702 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
19703         LDKCommitmentTransaction obj_conv;
19704         obj_conv.inner = (void*)(obj & (~1));
19705         obj_conv.is_owned = false;
19706         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
19707         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19708         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19709         CVec_u8Z_free(ret_var);
19710         return ret_arr;
19711 }
19712
19713 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
19714         LDKu8slice ser_ref;
19715         ser_ref.datalen = *((uint32_t*)ser);
19716         ser_ref.data = (int8_t*)(ser + 4);
19717         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
19718         *ret_conv = CommitmentTransaction_read(ser_ref);
19719         return (uint64_t)ret_conv;
19720 }
19721
19722 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
19723         LDKCommitmentTransaction this_arg_conv;
19724         this_arg_conv.inner = (void*)(this_arg & (~1));
19725         this_arg_conv.is_owned = false;
19726         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
19727         return ret_val;
19728 }
19729
19730 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
19731         LDKCommitmentTransaction this_arg_conv;
19732         this_arg_conv.inner = (void*)(this_arg & (~1));
19733         this_arg_conv.is_owned = false;
19734         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
19735         return ret_val;
19736 }
19737
19738 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
19739         LDKCommitmentTransaction this_arg_conv;
19740         this_arg_conv.inner = (void*)(this_arg & (~1));
19741         this_arg_conv.is_owned = false;
19742         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
19743         return ret_val;
19744 }
19745
19746 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
19747         LDKCommitmentTransaction this_arg_conv;
19748         this_arg_conv.inner = (void*)(this_arg & (~1));
19749         this_arg_conv.is_owned = false;
19750         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
19751         return ret_val;
19752 }
19753
19754 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
19755         LDKCommitmentTransaction this_arg_conv;
19756         this_arg_conv.inner = (void*)(this_arg & (~1));
19757         this_arg_conv.is_owned = false;
19758         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
19759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19761         uint64_t ret_ref = (uint64_t)ret_var.inner;
19762         if (ret_var.is_owned) {
19763                 ret_ref |= 1;
19764         }
19765         return ret_ref;
19766 }
19767
19768 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
19769         LDKCommitmentTransaction this_arg_conv;
19770         this_arg_conv.inner = (void*)(this_arg & (~1));
19771         this_arg_conv.is_owned = false;
19772         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19773         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19774         channel_parameters_conv.is_owned = false;
19775         LDKChannelPublicKeys broadcaster_keys_conv;
19776         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
19777         broadcaster_keys_conv.is_owned = false;
19778         LDKChannelPublicKeys countersignatory_keys_conv;
19779         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
19780         countersignatory_keys_conv.is_owned = false;
19781         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
19782         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
19783         return (uint64_t)ret_conv;
19784 }
19785
19786 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
19787         LDKTrustedCommitmentTransaction this_obj_conv;
19788         this_obj_conv.inner = (void*)(this_obj & (~1));
19789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19790         TrustedCommitmentTransaction_free(this_obj_conv);
19791 }
19792
19793 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
19794         LDKTrustedCommitmentTransaction this_arg_conv;
19795         this_arg_conv.inner = (void*)(this_arg & (~1));
19796         this_arg_conv.is_owned = false;
19797         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19798         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
19799         return ret_arr;
19800 }
19801
19802 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
19803         LDKTrustedCommitmentTransaction this_arg_conv;
19804         this_arg_conv.inner = (void*)(this_arg & (~1));
19805         this_arg_conv.is_owned = false;
19806         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
19807         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19808         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19809         uint64_t ret_ref = (uint64_t)ret_var.inner;
19810         if (ret_var.is_owned) {
19811                 ret_ref |= 1;
19812         }
19813         return ret_ref;
19814 }
19815
19816 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
19817         LDKTrustedCommitmentTransaction this_arg_conv;
19818         this_arg_conv.inner = (void*)(this_arg & (~1));
19819         this_arg_conv.is_owned = false;
19820         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
19821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19823         uint64_t ret_ref = (uint64_t)ret_var.inner;
19824         if (ret_var.is_owned) {
19825                 ret_ref |= 1;
19826         }
19827         return ret_ref;
19828 }
19829
19830 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
19831         LDKTrustedCommitmentTransaction this_arg_conv;
19832         this_arg_conv.inner = (void*)(this_arg & (~1));
19833         this_arg_conv.is_owned = false;
19834         unsigned char htlc_base_key_arr[32];
19835         CHECK(*((uint32_t*)htlc_base_key) == 32);
19836         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
19837         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
19838         LDKDirectedChannelTransactionParameters channel_parameters_conv;
19839         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
19840         channel_parameters_conv.is_owned = false;
19841         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
19842         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
19843         return (uint64_t)ret_conv;
19844 }
19845
19846 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) {
19847         LDKPublicKey broadcaster_payment_basepoint_ref;
19848         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
19849         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
19850         LDKPublicKey countersignatory_payment_basepoint_ref;
19851         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
19852         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
19853         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
19854         return ret_val;
19855 }
19856
19857 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
19858         LDKInitFeatures a_conv;
19859         a_conv.inner = (void*)(a & (~1));
19860         a_conv.is_owned = false;
19861         LDKInitFeatures b_conv;
19862         b_conv.inner = (void*)(b & (~1));
19863         b_conv.is_owned = false;
19864         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
19865         return ret_val;
19866 }
19867
19868 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
19869         LDKNodeFeatures a_conv;
19870         a_conv.inner = (void*)(a & (~1));
19871         a_conv.is_owned = false;
19872         LDKNodeFeatures b_conv;
19873         b_conv.inner = (void*)(b & (~1));
19874         b_conv.is_owned = false;
19875         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
19876         return ret_val;
19877 }
19878
19879 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
19880         LDKChannelFeatures a_conv;
19881         a_conv.inner = (void*)(a & (~1));
19882         a_conv.is_owned = false;
19883         LDKChannelFeatures b_conv;
19884         b_conv.inner = (void*)(b & (~1));
19885         b_conv.is_owned = false;
19886         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
19887         return ret_val;
19888 }
19889
19890 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
19891         LDKInvoiceFeatures a_conv;
19892         a_conv.inner = (void*)(a & (~1));
19893         a_conv.is_owned = false;
19894         LDKInvoiceFeatures b_conv;
19895         b_conv.inner = (void*)(b & (~1));
19896         b_conv.is_owned = false;
19897         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
19898         return ret_val;
19899 }
19900
19901 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
19902         LDKInitFeatures orig_conv;
19903         orig_conv.inner = (void*)(orig & (~1));
19904         orig_conv.is_owned = false;
19905         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
19906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19908         uint64_t ret_ref = (uint64_t)ret_var.inner;
19909         if (ret_var.is_owned) {
19910                 ret_ref |= 1;
19911         }
19912         return ret_ref;
19913 }
19914
19915 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
19916         LDKNodeFeatures orig_conv;
19917         orig_conv.inner = (void*)(orig & (~1));
19918         orig_conv.is_owned = false;
19919         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
19920         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19921         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19922         uint64_t ret_ref = (uint64_t)ret_var.inner;
19923         if (ret_var.is_owned) {
19924                 ret_ref |= 1;
19925         }
19926         return ret_ref;
19927 }
19928
19929 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
19930         LDKChannelFeatures orig_conv;
19931         orig_conv.inner = (void*)(orig & (~1));
19932         orig_conv.is_owned = false;
19933         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
19934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19936         uint64_t ret_ref = (uint64_t)ret_var.inner;
19937         if (ret_var.is_owned) {
19938                 ret_ref |= 1;
19939         }
19940         return ret_ref;
19941 }
19942
19943 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
19944         LDKInvoiceFeatures orig_conv;
19945         orig_conv.inner = (void*)(orig & (~1));
19946         orig_conv.is_owned = false;
19947         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
19948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19950         uint64_t ret_ref = (uint64_t)ret_var.inner;
19951         if (ret_var.is_owned) {
19952                 ret_ref |= 1;
19953         }
19954         return ret_ref;
19955 }
19956
19957 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
19958         LDKInitFeatures this_obj_conv;
19959         this_obj_conv.inner = (void*)(this_obj & (~1));
19960         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19961         InitFeatures_free(this_obj_conv);
19962 }
19963
19964 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
19965         LDKNodeFeatures this_obj_conv;
19966         this_obj_conv.inner = (void*)(this_obj & (~1));
19967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19968         NodeFeatures_free(this_obj_conv);
19969 }
19970
19971 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
19972         LDKChannelFeatures this_obj_conv;
19973         this_obj_conv.inner = (void*)(this_obj & (~1));
19974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19975         ChannelFeatures_free(this_obj_conv);
19976 }
19977
19978 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
19979         LDKInvoiceFeatures this_obj_conv;
19980         this_obj_conv.inner = (void*)(this_obj & (~1));
19981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19982         InvoiceFeatures_free(this_obj_conv);
19983 }
19984
19985 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
19986         LDKInitFeatures ret_var = InitFeatures_empty();
19987         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19988         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19989         uint64_t ret_ref = (uint64_t)ret_var.inner;
19990         if (ret_var.is_owned) {
19991                 ret_ref |= 1;
19992         }
19993         return ret_ref;
19994 }
19995
19996 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
19997         LDKInitFeatures ret_var = InitFeatures_known();
19998         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19999         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20000         uint64_t ret_ref = (uint64_t)ret_var.inner;
20001         if (ret_var.is_owned) {
20002                 ret_ref |= 1;
20003         }
20004         return ret_ref;
20005 }
20006
20007 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
20008         LDKNodeFeatures ret_var = NodeFeatures_empty();
20009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20011         uint64_t ret_ref = (uint64_t)ret_var.inner;
20012         if (ret_var.is_owned) {
20013                 ret_ref |= 1;
20014         }
20015         return ret_ref;
20016 }
20017
20018 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
20019         LDKNodeFeatures ret_var = NodeFeatures_known();
20020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20022         uint64_t ret_ref = (uint64_t)ret_var.inner;
20023         if (ret_var.is_owned) {
20024                 ret_ref |= 1;
20025         }
20026         return ret_ref;
20027 }
20028
20029 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
20030         LDKChannelFeatures ret_var = ChannelFeatures_empty();
20031         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20032         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20033         uint64_t ret_ref = (uint64_t)ret_var.inner;
20034         if (ret_var.is_owned) {
20035                 ret_ref |= 1;
20036         }
20037         return ret_ref;
20038 }
20039
20040 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
20041         LDKChannelFeatures ret_var = ChannelFeatures_known();
20042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20044         uint64_t ret_ref = (uint64_t)ret_var.inner;
20045         if (ret_var.is_owned) {
20046                 ret_ref |= 1;
20047         }
20048         return ret_ref;
20049 }
20050
20051 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
20052         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
20053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20055         uint64_t ret_ref = (uint64_t)ret_var.inner;
20056         if (ret_var.is_owned) {
20057                 ret_ref |= 1;
20058         }
20059         return ret_ref;
20060 }
20061
20062 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
20063         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
20064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20066         uint64_t ret_ref = (uint64_t)ret_var.inner;
20067         if (ret_var.is_owned) {
20068                 ret_ref |= 1;
20069         }
20070         return ret_ref;
20071 }
20072
20073 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
20074         LDKInitFeatures this_arg_conv;
20075         this_arg_conv.inner = (void*)(this_arg & (~1));
20076         this_arg_conv.is_owned = false;
20077         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
20078         return ret_val;
20079 }
20080
20081 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
20082         LDKNodeFeatures this_arg_conv;
20083         this_arg_conv.inner = (void*)(this_arg & (~1));
20084         this_arg_conv.is_owned = false;
20085         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
20086         return ret_val;
20087 }
20088
20089 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
20090         LDKInvoiceFeatures this_arg_conv;
20091         this_arg_conv.inner = (void*)(this_arg & (~1));
20092         this_arg_conv.is_owned = false;
20093         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
20094         return ret_val;
20095 }
20096
20097 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
20098         LDKInitFeatures obj_conv;
20099         obj_conv.inner = (void*)(obj & (~1));
20100         obj_conv.is_owned = false;
20101         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
20102         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20103         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20104         CVec_u8Z_free(ret_var);
20105         return ret_arr;
20106 }
20107
20108 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
20109         LDKNodeFeatures obj_conv;
20110         obj_conv.inner = (void*)(obj & (~1));
20111         obj_conv.is_owned = false;
20112         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
20113         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20114         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20115         CVec_u8Z_free(ret_var);
20116         return ret_arr;
20117 }
20118
20119 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
20120         LDKChannelFeatures obj_conv;
20121         obj_conv.inner = (void*)(obj & (~1));
20122         obj_conv.is_owned = false;
20123         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
20124         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20125         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20126         CVec_u8Z_free(ret_var);
20127         return ret_arr;
20128 }
20129
20130 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
20131         LDKInvoiceFeatures obj_conv;
20132         obj_conv.inner = (void*)(obj & (~1));
20133         obj_conv.is_owned = false;
20134         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
20135         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20136         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20137         CVec_u8Z_free(ret_var);
20138         return ret_arr;
20139 }
20140
20141 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
20142         LDKu8slice ser_ref;
20143         ser_ref.datalen = *((uint32_t*)ser);
20144         ser_ref.data = (int8_t*)(ser + 4);
20145         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
20146         *ret_conv = InitFeatures_read(ser_ref);
20147         return (uint64_t)ret_conv;
20148 }
20149
20150 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
20151         LDKu8slice ser_ref;
20152         ser_ref.datalen = *((uint32_t*)ser);
20153         ser_ref.data = (int8_t*)(ser + 4);
20154         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
20155         *ret_conv = NodeFeatures_read(ser_ref);
20156         return (uint64_t)ret_conv;
20157 }
20158
20159 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
20160         LDKu8slice ser_ref;
20161         ser_ref.datalen = *((uint32_t*)ser);
20162         ser_ref.data = (int8_t*)(ser + 4);
20163         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
20164         *ret_conv = ChannelFeatures_read(ser_ref);
20165         return (uint64_t)ret_conv;
20166 }
20167
20168 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
20169         LDKu8slice ser_ref;
20170         ser_ref.datalen = *((uint32_t*)ser);
20171         ser_ref.data = (int8_t*)(ser + 4);
20172         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
20173         *ret_conv = InvoiceFeatures_read(ser_ref);
20174         return (uint64_t)ret_conv;
20175 }
20176
20177 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
20178         LDKRouteHop this_obj_conv;
20179         this_obj_conv.inner = (void*)(this_obj & (~1));
20180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20181         RouteHop_free(this_obj_conv);
20182 }
20183
20184 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
20185         LDKRouteHop this_ptr_conv;
20186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20187         this_ptr_conv.is_owned = false;
20188         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20189         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
20190         return ret_arr;
20191 }
20192
20193 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
20194         LDKRouteHop this_ptr_conv;
20195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20196         this_ptr_conv.is_owned = false;
20197         LDKPublicKey val_ref;
20198         CHECK(*((uint32_t*)val) == 33);
20199         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20200         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
20201 }
20202
20203 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
20204         LDKRouteHop this_ptr_conv;
20205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20206         this_ptr_conv.is_owned = false;
20207         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
20208         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20209         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20210         uint64_t ret_ref = (uint64_t)ret_var.inner;
20211         if (ret_var.is_owned) {
20212                 ret_ref |= 1;
20213         }
20214         return ret_ref;
20215 }
20216
20217 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
20218         LDKRouteHop this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         LDKNodeFeatures val_conv;
20222         val_conv.inner = (void*)(val & (~1));
20223         val_conv.is_owned = (val & 1) || (val == 0);
20224         val_conv = NodeFeatures_clone(&val_conv);
20225         RouteHop_set_node_features(&this_ptr_conv, val_conv);
20226 }
20227
20228 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
20229         LDKRouteHop this_ptr_conv;
20230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20231         this_ptr_conv.is_owned = false;
20232         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
20233         return ret_val;
20234 }
20235
20236 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20237         LDKRouteHop this_ptr_conv;
20238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20239         this_ptr_conv.is_owned = false;
20240         RouteHop_set_short_channel_id(&this_ptr_conv, val);
20241 }
20242
20243 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
20244         LDKRouteHop this_ptr_conv;
20245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20246         this_ptr_conv.is_owned = false;
20247         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
20248         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20249         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20250         uint64_t ret_ref = (uint64_t)ret_var.inner;
20251         if (ret_var.is_owned) {
20252                 ret_ref |= 1;
20253         }
20254         return ret_ref;
20255 }
20256
20257 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
20258         LDKRouteHop this_ptr_conv;
20259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20260         this_ptr_conv.is_owned = false;
20261         LDKChannelFeatures val_conv;
20262         val_conv.inner = (void*)(val & (~1));
20263         val_conv.is_owned = (val & 1) || (val == 0);
20264         val_conv = ChannelFeatures_clone(&val_conv);
20265         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
20266 }
20267
20268 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
20269         LDKRouteHop this_ptr_conv;
20270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20271         this_ptr_conv.is_owned = false;
20272         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
20273         return ret_val;
20274 }
20275
20276 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
20277         LDKRouteHop this_ptr_conv;
20278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20279         this_ptr_conv.is_owned = false;
20280         RouteHop_set_fee_msat(&this_ptr_conv, val);
20281 }
20282
20283 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20284         LDKRouteHop this_ptr_conv;
20285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20286         this_ptr_conv.is_owned = false;
20287         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
20288         return ret_val;
20289 }
20290
20291 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
20292         LDKRouteHop this_ptr_conv;
20293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20294         this_ptr_conv.is_owned = false;
20295         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20296 }
20297
20298 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) {
20299         LDKPublicKey pubkey_arg_ref;
20300         CHECK(*((uint32_t*)pubkey_arg) == 33);
20301         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
20302         LDKNodeFeatures node_features_arg_conv;
20303         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
20304         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
20305         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
20306         LDKChannelFeatures channel_features_arg_conv;
20307         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
20308         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
20309         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
20310         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);
20311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20313         uint64_t ret_ref = (uint64_t)ret_var.inner;
20314         if (ret_var.is_owned) {
20315                 ret_ref |= 1;
20316         }
20317         return ret_ref;
20318 }
20319
20320 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
20321         LDKRouteHop orig_conv;
20322         orig_conv.inner = (void*)(orig & (~1));
20323         orig_conv.is_owned = false;
20324         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
20325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20327         uint64_t ret_ref = (uint64_t)ret_var.inner;
20328         if (ret_var.is_owned) {
20329                 ret_ref |= 1;
20330         }
20331         return ret_ref;
20332 }
20333
20334 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
20335         LDKRouteHop obj_conv;
20336         obj_conv.inner = (void*)(obj & (~1));
20337         obj_conv.is_owned = false;
20338         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
20339         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20340         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20341         CVec_u8Z_free(ret_var);
20342         return ret_arr;
20343 }
20344
20345 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
20346         LDKu8slice ser_ref;
20347         ser_ref.datalen = *((uint32_t*)ser);
20348         ser_ref.data = (int8_t*)(ser + 4);
20349         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
20350         *ret_conv = RouteHop_read(ser_ref);
20351         return (uint64_t)ret_conv;
20352 }
20353
20354 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
20355         LDKRoute this_obj_conv;
20356         this_obj_conv.inner = (void*)(this_obj & (~1));
20357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20358         Route_free(this_obj_conv);
20359 }
20360
20361 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
20362         LDKRoute this_ptr_conv;
20363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20364         this_ptr_conv.is_owned = false;
20365         LDKCVec_CVec_RouteHopZZ val_constr;
20366         val_constr.datalen = *((uint32_t*)val);
20367         if (val_constr.datalen > 0)
20368                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20369         else
20370                 val_constr.data = NULL;
20371         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
20372         for (size_t m = 0; m < val_constr.datalen; m++) {
20373                 uint32_tArray val_conv_12 = val_vals[m];
20374                 LDKCVec_RouteHopZ val_conv_12_constr;
20375                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
20376                 if (val_conv_12_constr.datalen > 0)
20377                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20378                 else
20379                         val_conv_12_constr.data = NULL;
20380                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
20381                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
20382                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
20383                         LDKRouteHop val_conv_12_conv_10_conv;
20384                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
20385                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
20386                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
20387                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
20388                 }
20389                 val_constr.data[m] = val_conv_12_constr;
20390         }
20391         Route_set_paths(&this_ptr_conv, val_constr);
20392 }
20393
20394 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
20395         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
20396         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
20397         if (paths_arg_constr.datalen > 0)
20398                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
20399         else
20400                 paths_arg_constr.data = NULL;
20401         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
20402         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
20403                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
20404                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
20405                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
20406                 if (paths_arg_conv_12_constr.datalen > 0)
20407                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20408                 else
20409                         paths_arg_conv_12_constr.data = NULL;
20410                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
20411                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
20412                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
20413                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
20414                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
20415                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
20416                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
20417                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
20418                 }
20419                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
20420         }
20421         LDKRoute ret_var = Route_new(paths_arg_constr);
20422         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20423         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20424         uint64_t ret_ref = (uint64_t)ret_var.inner;
20425         if (ret_var.is_owned) {
20426                 ret_ref |= 1;
20427         }
20428         return ret_ref;
20429 }
20430
20431 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
20432         LDKRoute orig_conv;
20433         orig_conv.inner = (void*)(orig & (~1));
20434         orig_conv.is_owned = false;
20435         LDKRoute ret_var = Route_clone(&orig_conv);
20436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20438         uint64_t ret_ref = (uint64_t)ret_var.inner;
20439         if (ret_var.is_owned) {
20440                 ret_ref |= 1;
20441         }
20442         return ret_ref;
20443 }
20444
20445 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
20446         LDKRoute obj_conv;
20447         obj_conv.inner = (void*)(obj & (~1));
20448         obj_conv.is_owned = false;
20449         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
20450         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20451         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20452         CVec_u8Z_free(ret_var);
20453         return ret_arr;
20454 }
20455
20456 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
20457         LDKu8slice ser_ref;
20458         ser_ref.datalen = *((uint32_t*)ser);
20459         ser_ref.data = (int8_t*)(ser + 4);
20460         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
20461         *ret_conv = Route_read(ser_ref);
20462         return (uint64_t)ret_conv;
20463 }
20464
20465 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
20466         LDKRouteHint this_obj_conv;
20467         this_obj_conv.inner = (void*)(this_obj & (~1));
20468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20469         RouteHint_free(this_obj_conv);
20470 }
20471
20472 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
20473         LDKRouteHint a_conv;
20474         a_conv.inner = (void*)(a & (~1));
20475         a_conv.is_owned = false;
20476         LDKRouteHint b_conv;
20477         b_conv.inner = (void*)(b & (~1));
20478         b_conv.is_owned = false;
20479         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
20480         return ret_val;
20481 }
20482
20483 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
20484         LDKRouteHint orig_conv;
20485         orig_conv.inner = (void*)(orig & (~1));
20486         orig_conv.is_owned = false;
20487         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
20488         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20489         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20490         uint64_t ret_ref = (uint64_t)ret_var.inner;
20491         if (ret_var.is_owned) {
20492                 ret_ref |= 1;
20493         }
20494         return ret_ref;
20495 }
20496
20497 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
20498         LDKRouteHintHop this_obj_conv;
20499         this_obj_conv.inner = (void*)(this_obj & (~1));
20500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20501         RouteHintHop_free(this_obj_conv);
20502 }
20503
20504 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
20505         LDKRouteHintHop this_ptr_conv;
20506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20507         this_ptr_conv.is_owned = false;
20508         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20509         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
20510         return ret_arr;
20511 }
20512
20513 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
20514         LDKRouteHintHop this_ptr_conv;
20515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20516         this_ptr_conv.is_owned = false;
20517         LDKPublicKey val_ref;
20518         CHECK(*((uint32_t*)val) == 33);
20519         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20520         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
20521 }
20522
20523 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
20524         LDKRouteHintHop this_ptr_conv;
20525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20526         this_ptr_conv.is_owned = false;
20527         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
20528         return ret_val;
20529 }
20530
20531 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
20532         LDKRouteHintHop this_ptr_conv;
20533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20534         this_ptr_conv.is_owned = false;
20535         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
20536 }
20537
20538 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
20539         LDKRouteHintHop this_ptr_conv;
20540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20541         this_ptr_conv.is_owned = false;
20542         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
20543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20545         uint64_t ret_ref = (uint64_t)ret_var.inner;
20546         if (ret_var.is_owned) {
20547                 ret_ref |= 1;
20548         }
20549         return ret_ref;
20550 }
20551
20552 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
20553         LDKRouteHintHop this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         LDKRoutingFees val_conv;
20557         val_conv.inner = (void*)(val & (~1));
20558         val_conv.is_owned = (val & 1) || (val == 0);
20559         val_conv = RoutingFees_clone(&val_conv);
20560         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
20561 }
20562
20563 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
20564         LDKRouteHintHop this_ptr_conv;
20565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20566         this_ptr_conv.is_owned = false;
20567         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
20568         return ret_val;
20569 }
20570
20571 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20572         LDKRouteHintHop this_ptr_conv;
20573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20574         this_ptr_conv.is_owned = false;
20575         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
20576 }
20577
20578 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
20579         LDKRouteHintHop this_ptr_conv;
20580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20581         this_ptr_conv.is_owned = false;
20582         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20583         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
20584         uint64_t ret_ref = (uint64_t)ret_copy;
20585         return ret_ref;
20586 }
20587
20588 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
20589         LDKRouteHintHop this_ptr_conv;
20590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20591         this_ptr_conv.is_owned = false;
20592         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20593         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
20594 }
20595
20596 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
20597         LDKRouteHintHop this_ptr_conv;
20598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20599         this_ptr_conv.is_owned = false;
20600         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20601         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
20602         uint64_t ret_ref = (uint64_t)ret_copy;
20603         return ret_ref;
20604 }
20605
20606 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20607         LDKRouteHintHop this_ptr_conv;
20608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20609         this_ptr_conv.is_owned = false;
20610         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20611         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20612 }
20613
20614 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) {
20615         LDKPublicKey src_node_id_arg_ref;
20616         CHECK(*((uint32_t*)src_node_id_arg) == 33);
20617         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
20618         LDKRoutingFees fees_arg_conv;
20619         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20620         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20621         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20622         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
20623         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20624         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);
20625         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20626         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20627         uint64_t ret_ref = (uint64_t)ret_var.inner;
20628         if (ret_var.is_owned) {
20629                 ret_ref |= 1;
20630         }
20631         return ret_ref;
20632 }
20633
20634 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
20635         LDKRouteHintHop a_conv;
20636         a_conv.inner = (void*)(a & (~1));
20637         a_conv.is_owned = false;
20638         LDKRouteHintHop b_conv;
20639         b_conv.inner = (void*)(b & (~1));
20640         b_conv.is_owned = false;
20641         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
20642         return ret_val;
20643 }
20644
20645 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
20646         LDKRouteHintHop orig_conv;
20647         orig_conv.inner = (void*)(orig & (~1));
20648         orig_conv.is_owned = false;
20649         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
20650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20652         uint64_t ret_ref = (uint64_t)ret_var.inner;
20653         if (ret_var.is_owned) {
20654                 ret_ref |= 1;
20655         }
20656         return ret_ref;
20657 }
20658
20659 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) {
20660         LDKPublicKey our_node_id_ref;
20661         CHECK(*((uint32_t*)our_node_id) == 33);
20662         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
20663         LDKNetworkGraph network_conv;
20664         network_conv.inner = (void*)(network & (~1));
20665         network_conv.is_owned = false;
20666         LDKPublicKey payee_ref;
20667         CHECK(*((uint32_t*)payee) == 33);
20668         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
20669         LDKInvoiceFeatures payee_features_conv;
20670         payee_features_conv.inner = (void*)(payee_features & (~1));
20671         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
20672         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
20673         LDKCVec_ChannelDetailsZ first_hops_constr;
20674         first_hops_constr.datalen = *((uint32_t*)first_hops);
20675         if (first_hops_constr.datalen > 0)
20676                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
20677         else
20678                 first_hops_constr.data = NULL;
20679         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
20680         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
20681                 uint32_t first_hops_conv_16 = first_hops_vals[q];
20682                 LDKChannelDetails first_hops_conv_16_conv;
20683                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
20684                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
20685                 first_hops_constr.data[q] = first_hops_conv_16_conv;
20686         }
20687         LDKCVec_RouteHintZ last_hops_constr;
20688         last_hops_constr.datalen = *((uint32_t*)last_hops);
20689         if (last_hops_constr.datalen > 0)
20690                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
20691         else
20692                 last_hops_constr.data = NULL;
20693         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
20694         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
20695                 uint32_t last_hops_conv_11 = last_hops_vals[l];
20696                 LDKRouteHint last_hops_conv_11_conv;
20697                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
20698                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
20699                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
20700                 last_hops_constr.data[l] = last_hops_conv_11_conv;
20701         }
20702         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20703         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
20704         *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);
20705         FREE(first_hops_constr.data);
20706         return (uint64_t)ret_conv;
20707 }
20708
20709 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
20710         LDKNetworkGraph this_obj_conv;
20711         this_obj_conv.inner = (void*)(this_obj & (~1));
20712         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20713         NetworkGraph_free(this_obj_conv);
20714 }
20715
20716 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
20717         LDKNetworkGraph orig_conv;
20718         orig_conv.inner = (void*)(orig & (~1));
20719         orig_conv.is_owned = false;
20720         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
20721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20723         uint64_t ret_ref = (uint64_t)ret_var.inner;
20724         if (ret_var.is_owned) {
20725                 ret_ref |= 1;
20726         }
20727         return ret_ref;
20728 }
20729
20730 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
20731         LDKLockedNetworkGraph this_obj_conv;
20732         this_obj_conv.inner = (void*)(this_obj & (~1));
20733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20734         LockedNetworkGraph_free(this_obj_conv);
20735 }
20736
20737 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
20738         LDKNetGraphMsgHandler this_obj_conv;
20739         this_obj_conv.inner = (void*)(this_obj & (~1));
20740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20741         NetGraphMsgHandler_free(this_obj_conv);
20742 }
20743
20744 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
20745         LDKThirtyTwoBytes genesis_hash_ref;
20746         CHECK(*((uint32_t*)genesis_hash) == 32);
20747         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
20748         LDKAccess *chain_access_conv_ptr = NULL;
20749         if (chain_access != 0) {
20750                 LDKAccess chain_access_conv;
20751                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20752                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20753                 *chain_access_conv_ptr = chain_access_conv;
20754         }
20755         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20756         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
20757         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20758         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20759         uint64_t ret_ref = (uint64_t)ret_var.inner;
20760         if (ret_var.is_owned) {
20761                 ret_ref |= 1;
20762         }
20763         return ret_ref;
20764 }
20765
20766 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
20767         LDKAccess *chain_access_conv_ptr = NULL;
20768         if (chain_access != 0) {
20769                 LDKAccess chain_access_conv;
20770                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20771                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20772                 *chain_access_conv_ptr = chain_access_conv;
20773         }
20774         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
20775         LDKNetworkGraph network_graph_conv;
20776         network_graph_conv.inner = (void*)(network_graph & (~1));
20777         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
20778         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
20779         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
20780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20782         uint64_t ret_ref = (uint64_t)ret_var.inner;
20783         if (ret_var.is_owned) {
20784                 ret_ref |= 1;
20785         }
20786         return ret_ref;
20787 }
20788
20789 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
20790         LDKNetGraphMsgHandler this_arg_conv;
20791         this_arg_conv.inner = (void*)(this_arg & (~1));
20792         this_arg_conv.is_owned = false;
20793         LDKAccess *chain_access_conv_ptr = NULL;
20794         if (chain_access != 0) {
20795                 LDKAccess chain_access_conv;
20796                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
20797                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
20798                 *chain_access_conv_ptr = chain_access_conv;
20799         }
20800         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
20801 }
20802
20803 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
20804         LDKNetGraphMsgHandler this_arg_conv;
20805         this_arg_conv.inner = (void*)(this_arg & (~1));
20806         this_arg_conv.is_owned = false;
20807         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
20808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20810         uint64_t ret_ref = (uint64_t)ret_var.inner;
20811         if (ret_var.is_owned) {
20812                 ret_ref |= 1;
20813         }
20814         return ret_ref;
20815 }
20816
20817 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
20818         LDKLockedNetworkGraph this_arg_conv;
20819         this_arg_conv.inner = (void*)(this_arg & (~1));
20820         this_arg_conv.is_owned = false;
20821         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
20822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20824         uint64_t ret_ref = (uint64_t)ret_var.inner;
20825         if (ret_var.is_owned) {
20826                 ret_ref |= 1;
20827         }
20828         return ret_ref;
20829 }
20830
20831 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
20832         LDKNetGraphMsgHandler this_arg_conv;
20833         this_arg_conv.inner = (void*)(this_arg & (~1));
20834         this_arg_conv.is_owned = false;
20835         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20836         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
20837         return (uint64_t)ret;
20838 }
20839
20840 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20841         LDKNetGraphMsgHandler this_arg_conv;
20842         this_arg_conv.inner = (void*)(this_arg & (~1));
20843         this_arg_conv.is_owned = false;
20844         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20845         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
20846         return (uint64_t)ret;
20847 }
20848
20849 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
20850         LDKDirectionalChannelInfo this_obj_conv;
20851         this_obj_conv.inner = (void*)(this_obj & (~1));
20852         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20853         DirectionalChannelInfo_free(this_obj_conv);
20854 }
20855
20856 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
20857         LDKDirectionalChannelInfo this_ptr_conv;
20858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20859         this_ptr_conv.is_owned = false;
20860         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
20861         return ret_val;
20862 }
20863
20864 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
20865         LDKDirectionalChannelInfo this_ptr_conv;
20866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20867         this_ptr_conv.is_owned = false;
20868         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
20869 }
20870
20871 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
20872         LDKDirectionalChannelInfo this_ptr_conv;
20873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20874         this_ptr_conv.is_owned = false;
20875         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
20876         return ret_val;
20877 }
20878
20879 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
20880         LDKDirectionalChannelInfo this_ptr_conv;
20881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20882         this_ptr_conv.is_owned = false;
20883         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
20884 }
20885
20886 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20887         LDKDirectionalChannelInfo this_ptr_conv;
20888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20889         this_ptr_conv.is_owned = false;
20890         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
20891         return ret_val;
20892 }
20893
20894 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20895         LDKDirectionalChannelInfo this_ptr_conv;
20896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20897         this_ptr_conv.is_owned = false;
20898         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20899 }
20900
20901 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
20902         LDKDirectionalChannelInfo this_ptr_conv;
20903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20904         this_ptr_conv.is_owned = false;
20905         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
20906         return ret_val;
20907 }
20908
20909 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
20910         LDKDirectionalChannelInfo this_ptr_conv;
20911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20912         this_ptr_conv.is_owned = false;
20913         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
20914 }
20915
20916 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
20917         LDKDirectionalChannelInfo this_ptr_conv;
20918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20919         this_ptr_conv.is_owned = false;
20920         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20921         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
20922         uint64_t ret_ref = (uint64_t)ret_copy;
20923         return ret_ref;
20924 }
20925
20926 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
20927         LDKDirectionalChannelInfo this_ptr_conv;
20928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20929         this_ptr_conv.is_owned = false;
20930         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
20931         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
20932 }
20933
20934 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
20935         LDKDirectionalChannelInfo this_ptr_conv;
20936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20937         this_ptr_conv.is_owned = false;
20938         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
20939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20941         uint64_t ret_ref = (uint64_t)ret_var.inner;
20942         if (ret_var.is_owned) {
20943                 ret_ref |= 1;
20944         }
20945         return ret_ref;
20946 }
20947
20948 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
20949         LDKDirectionalChannelInfo this_ptr_conv;
20950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20951         this_ptr_conv.is_owned = false;
20952         LDKRoutingFees val_conv;
20953         val_conv.inner = (void*)(val & (~1));
20954         val_conv.is_owned = (val & 1) || (val == 0);
20955         val_conv = RoutingFees_clone(&val_conv);
20956         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
20957 }
20958
20959 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
20960         LDKDirectionalChannelInfo this_ptr_conv;
20961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20962         this_ptr_conv.is_owned = false;
20963         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
20964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20966         uint64_t ret_ref = (uint64_t)ret_var.inner;
20967         if (ret_var.is_owned) {
20968                 ret_ref |= 1;
20969         }
20970         return ret_ref;
20971 }
20972
20973 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
20974         LDKDirectionalChannelInfo this_ptr_conv;
20975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20976         this_ptr_conv.is_owned = false;
20977         LDKChannelUpdate val_conv;
20978         val_conv.inner = (void*)(val & (~1));
20979         val_conv.is_owned = (val & 1) || (val == 0);
20980         val_conv = ChannelUpdate_clone(&val_conv);
20981         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
20982 }
20983
20984 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) {
20985         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
20986         LDKRoutingFees fees_arg_conv;
20987         fees_arg_conv.inner = (void*)(fees_arg & (~1));
20988         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
20989         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
20990         LDKChannelUpdate last_update_message_arg_conv;
20991         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
20992         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
20993         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
20994         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);
20995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20997         uint64_t ret_ref = (uint64_t)ret_var.inner;
20998         if (ret_var.is_owned) {
20999                 ret_ref |= 1;
21000         }
21001         return ret_ref;
21002 }
21003
21004 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
21005         LDKDirectionalChannelInfo orig_conv;
21006         orig_conv.inner = (void*)(orig & (~1));
21007         orig_conv.is_owned = false;
21008         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_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 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
21019         LDKDirectionalChannelInfo obj_conv;
21020         obj_conv.inner = (void*)(obj & (~1));
21021         obj_conv.is_owned = false;
21022         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
21023         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21024         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21025         CVec_u8Z_free(ret_var);
21026         return ret_arr;
21027 }
21028
21029 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
21030         LDKu8slice ser_ref;
21031         ser_ref.datalen = *((uint32_t*)ser);
21032         ser_ref.data = (int8_t*)(ser + 4);
21033         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
21034         *ret_conv = DirectionalChannelInfo_read(ser_ref);
21035         return (uint64_t)ret_conv;
21036 }
21037
21038 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
21039         LDKChannelInfo this_obj_conv;
21040         this_obj_conv.inner = (void*)(this_obj & (~1));
21041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21042         ChannelInfo_free(this_obj_conv);
21043 }
21044
21045 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
21046         LDKChannelInfo this_ptr_conv;
21047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21048         this_ptr_conv.is_owned = false;
21049         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
21050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21052         uint64_t ret_ref = (uint64_t)ret_var.inner;
21053         if (ret_var.is_owned) {
21054                 ret_ref |= 1;
21055         }
21056         return ret_ref;
21057 }
21058
21059 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
21060         LDKChannelInfo this_ptr_conv;
21061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21062         this_ptr_conv.is_owned = false;
21063         LDKChannelFeatures val_conv;
21064         val_conv.inner = (void*)(val & (~1));
21065         val_conv.is_owned = (val & 1) || (val == 0);
21066         val_conv = ChannelFeatures_clone(&val_conv);
21067         ChannelInfo_set_features(&this_ptr_conv, val_conv);
21068 }
21069
21070 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
21071         LDKChannelInfo this_ptr_conv;
21072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21073         this_ptr_conv.is_owned = false;
21074         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21075         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
21076         return ret_arr;
21077 }
21078
21079 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
21080         LDKChannelInfo this_ptr_conv;
21081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21082         this_ptr_conv.is_owned = false;
21083         LDKPublicKey val_ref;
21084         CHECK(*((uint32_t*)val) == 33);
21085         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21086         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
21087 }
21088
21089 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
21090         LDKChannelInfo this_ptr_conv;
21091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21092         this_ptr_conv.is_owned = false;
21093         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
21094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21096         uint64_t ret_ref = (uint64_t)ret_var.inner;
21097         if (ret_var.is_owned) {
21098                 ret_ref |= 1;
21099         }
21100         return ret_ref;
21101 }
21102
21103 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
21104         LDKChannelInfo this_ptr_conv;
21105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21106         this_ptr_conv.is_owned = false;
21107         LDKDirectionalChannelInfo val_conv;
21108         val_conv.inner = (void*)(val & (~1));
21109         val_conv.is_owned = (val & 1) || (val == 0);
21110         val_conv = DirectionalChannelInfo_clone(&val_conv);
21111         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
21112 }
21113
21114 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
21115         LDKChannelInfo this_ptr_conv;
21116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21117         this_ptr_conv.is_owned = false;
21118         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21119         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
21120         return ret_arr;
21121 }
21122
21123 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
21124         LDKChannelInfo this_ptr_conv;
21125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21126         this_ptr_conv.is_owned = false;
21127         LDKPublicKey val_ref;
21128         CHECK(*((uint32_t*)val) == 33);
21129         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21130         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
21131 }
21132
21133 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
21134         LDKChannelInfo this_ptr_conv;
21135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21136         this_ptr_conv.is_owned = false;
21137         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
21138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21140         uint64_t ret_ref = (uint64_t)ret_var.inner;
21141         if (ret_var.is_owned) {
21142                 ret_ref |= 1;
21143         }
21144         return ret_ref;
21145 }
21146
21147 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
21148         LDKChannelInfo this_ptr_conv;
21149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21150         this_ptr_conv.is_owned = false;
21151         LDKDirectionalChannelInfo val_conv;
21152         val_conv.inner = (void*)(val & (~1));
21153         val_conv.is_owned = (val & 1) || (val == 0);
21154         val_conv = DirectionalChannelInfo_clone(&val_conv);
21155         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
21156 }
21157
21158 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
21159         LDKChannelInfo this_ptr_conv;
21160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21161         this_ptr_conv.is_owned = false;
21162         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21163         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
21164         uint64_t ret_ref = (uint64_t)ret_copy;
21165         return ret_ref;
21166 }
21167
21168 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
21169         LDKChannelInfo this_ptr_conv;
21170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21171         this_ptr_conv.is_owned = false;
21172         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
21173         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
21174 }
21175
21176 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
21177         LDKChannelInfo this_ptr_conv;
21178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21179         this_ptr_conv.is_owned = false;
21180         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
21181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21183         uint64_t ret_ref = (uint64_t)ret_var.inner;
21184         if (ret_var.is_owned) {
21185                 ret_ref |= 1;
21186         }
21187         return ret_ref;
21188 }
21189
21190 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21191         LDKChannelInfo this_ptr_conv;
21192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21193         this_ptr_conv.is_owned = false;
21194         LDKChannelAnnouncement val_conv;
21195         val_conv.inner = (void*)(val & (~1));
21196         val_conv.is_owned = (val & 1) || (val == 0);
21197         val_conv = ChannelAnnouncement_clone(&val_conv);
21198         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
21199 }
21200
21201 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) {
21202         LDKChannelFeatures features_arg_conv;
21203         features_arg_conv.inner = (void*)(features_arg & (~1));
21204         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21205         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
21206         LDKPublicKey node_one_arg_ref;
21207         CHECK(*((uint32_t*)node_one_arg) == 33);
21208         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
21209         LDKDirectionalChannelInfo one_to_two_arg_conv;
21210         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
21211         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
21212         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
21213         LDKPublicKey node_two_arg_ref;
21214         CHECK(*((uint32_t*)node_two_arg) == 33);
21215         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
21216         LDKDirectionalChannelInfo two_to_one_arg_conv;
21217         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
21218         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
21219         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
21220         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
21221         LDKChannelAnnouncement announcement_message_arg_conv;
21222         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21223         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21224         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
21225         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);
21226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21228         uint64_t ret_ref = (uint64_t)ret_var.inner;
21229         if (ret_var.is_owned) {
21230                 ret_ref |= 1;
21231         }
21232         return ret_ref;
21233 }
21234
21235 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
21236         LDKChannelInfo orig_conv;
21237         orig_conv.inner = (void*)(orig & (~1));
21238         orig_conv.is_owned = false;
21239         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
21240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21242         uint64_t ret_ref = (uint64_t)ret_var.inner;
21243         if (ret_var.is_owned) {
21244                 ret_ref |= 1;
21245         }
21246         return ret_ref;
21247 }
21248
21249 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
21250         LDKChannelInfo obj_conv;
21251         obj_conv.inner = (void*)(obj & (~1));
21252         obj_conv.is_owned = false;
21253         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
21254         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21255         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21256         CVec_u8Z_free(ret_var);
21257         return ret_arr;
21258 }
21259
21260 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
21261         LDKu8slice ser_ref;
21262         ser_ref.datalen = *((uint32_t*)ser);
21263         ser_ref.data = (int8_t*)(ser + 4);
21264         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
21265         *ret_conv = ChannelInfo_read(ser_ref);
21266         return (uint64_t)ret_conv;
21267 }
21268
21269 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
21270         LDKRoutingFees this_obj_conv;
21271         this_obj_conv.inner = (void*)(this_obj & (~1));
21272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21273         RoutingFees_free(this_obj_conv);
21274 }
21275
21276 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
21277         LDKRoutingFees this_ptr_conv;
21278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21279         this_ptr_conv.is_owned = false;
21280         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
21281         return ret_val;
21282 }
21283
21284 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
21285         LDKRoutingFees this_ptr_conv;
21286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21287         this_ptr_conv.is_owned = false;
21288         RoutingFees_set_base_msat(&this_ptr_conv, val);
21289 }
21290
21291 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
21292         LDKRoutingFees this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
21296         return ret_val;
21297 }
21298
21299 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
21300         LDKRoutingFees this_ptr_conv;
21301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21302         this_ptr_conv.is_owned = false;
21303         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
21304 }
21305
21306 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
21307         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
21308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21310         uint64_t ret_ref = (uint64_t)ret_var.inner;
21311         if (ret_var.is_owned) {
21312                 ret_ref |= 1;
21313         }
21314         return ret_ref;
21315 }
21316
21317 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
21318         LDKRoutingFees a_conv;
21319         a_conv.inner = (void*)(a & (~1));
21320         a_conv.is_owned = false;
21321         LDKRoutingFees b_conv;
21322         b_conv.inner = (void*)(b & (~1));
21323         b_conv.is_owned = false;
21324         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
21325         return ret_val;
21326 }
21327
21328 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
21329         LDKRoutingFees orig_conv;
21330         orig_conv.inner = (void*)(orig & (~1));
21331         orig_conv.is_owned = false;
21332         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
21333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21335         uint64_t ret_ref = (uint64_t)ret_var.inner;
21336         if (ret_var.is_owned) {
21337                 ret_ref |= 1;
21338         }
21339         return ret_ref;
21340 }
21341
21342 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
21343         LDKRoutingFees obj_conv;
21344         obj_conv.inner = (void*)(obj & (~1));
21345         obj_conv.is_owned = false;
21346         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
21347         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21348         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21349         CVec_u8Z_free(ret_var);
21350         return ret_arr;
21351 }
21352
21353 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
21354         LDKu8slice ser_ref;
21355         ser_ref.datalen = *((uint32_t*)ser);
21356         ser_ref.data = (int8_t*)(ser + 4);
21357         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
21358         *ret_conv = RoutingFees_read(ser_ref);
21359         return (uint64_t)ret_conv;
21360 }
21361
21362 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
21363         LDKNodeAnnouncementInfo this_obj_conv;
21364         this_obj_conv.inner = (void*)(this_obj & (~1));
21365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21366         NodeAnnouncementInfo_free(this_obj_conv);
21367 }
21368
21369 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
21370         LDKNodeAnnouncementInfo this_ptr_conv;
21371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21372         this_ptr_conv.is_owned = false;
21373         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
21374         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21375         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21376         uint64_t ret_ref = (uint64_t)ret_var.inner;
21377         if (ret_var.is_owned) {
21378                 ret_ref |= 1;
21379         }
21380         return ret_ref;
21381 }
21382
21383 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
21384         LDKNodeAnnouncementInfo this_ptr_conv;
21385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21386         this_ptr_conv.is_owned = false;
21387         LDKNodeFeatures val_conv;
21388         val_conv.inner = (void*)(val & (~1));
21389         val_conv.is_owned = (val & 1) || (val == 0);
21390         val_conv = NodeFeatures_clone(&val_conv);
21391         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
21392 }
21393
21394 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
21395         LDKNodeAnnouncementInfo this_ptr_conv;
21396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21397         this_ptr_conv.is_owned = false;
21398         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
21399         return ret_val;
21400 }
21401
21402 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
21403         LDKNodeAnnouncementInfo this_ptr_conv;
21404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21405         this_ptr_conv.is_owned = false;
21406         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
21407 }
21408
21409 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
21410         LDKNodeAnnouncementInfo this_ptr_conv;
21411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21412         this_ptr_conv.is_owned = false;
21413         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
21414         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
21415         return ret_arr;
21416 }
21417
21418 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
21419         LDKNodeAnnouncementInfo this_ptr_conv;
21420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21421         this_ptr_conv.is_owned = false;
21422         LDKThreeBytes val_ref;
21423         CHECK(*((uint32_t*)val) == 3);
21424         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
21425         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
21426 }
21427
21428 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
21429         LDKNodeAnnouncementInfo this_ptr_conv;
21430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21431         this_ptr_conv.is_owned = false;
21432         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21433         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
21434         return ret_arr;
21435 }
21436
21437 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
21438         LDKNodeAnnouncementInfo this_ptr_conv;
21439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21440         this_ptr_conv.is_owned = false;
21441         LDKThirtyTwoBytes val_ref;
21442         CHECK(*((uint32_t*)val) == 32);
21443         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21444         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
21445 }
21446
21447 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
21448         LDKNodeAnnouncementInfo this_ptr_conv;
21449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21450         this_ptr_conv.is_owned = false;
21451         LDKCVec_NetAddressZ val_constr;
21452         val_constr.datalen = *((uint32_t*)val);
21453         if (val_constr.datalen > 0)
21454                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21455         else
21456                 val_constr.data = NULL;
21457         uint32_t* val_vals = (uint32_t*)(val + 4);
21458         for (size_t m = 0; m < val_constr.datalen; m++) {
21459                 uint32_t val_conv_12 = val_vals[m];
21460                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
21461                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
21462                 val_constr.data[m] = val_conv_12_conv;
21463         }
21464         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
21465 }
21466
21467 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
21468         LDKNodeAnnouncementInfo this_ptr_conv;
21469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21470         this_ptr_conv.is_owned = false;
21471         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
21472         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21473         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21474         uint64_t ret_ref = (uint64_t)ret_var.inner;
21475         if (ret_var.is_owned) {
21476                 ret_ref |= 1;
21477         }
21478         return ret_ref;
21479 }
21480
21481 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
21482         LDKNodeAnnouncementInfo this_ptr_conv;
21483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21484         this_ptr_conv.is_owned = false;
21485         LDKNodeAnnouncement val_conv;
21486         val_conv.inner = (void*)(val & (~1));
21487         val_conv.is_owned = (val & 1) || (val == 0);
21488         val_conv = NodeAnnouncement_clone(&val_conv);
21489         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
21490 }
21491
21492 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) {
21493         LDKNodeFeatures features_arg_conv;
21494         features_arg_conv.inner = (void*)(features_arg & (~1));
21495         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21496         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
21497         LDKThreeBytes rgb_arg_ref;
21498         CHECK(*((uint32_t*)rgb_arg) == 3);
21499         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
21500         LDKThirtyTwoBytes alias_arg_ref;
21501         CHECK(*((uint32_t*)alias_arg) == 32);
21502         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
21503         LDKCVec_NetAddressZ addresses_arg_constr;
21504         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
21505         if (addresses_arg_constr.datalen > 0)
21506                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21507         else
21508                 addresses_arg_constr.data = NULL;
21509         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
21510         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
21511                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
21512                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
21513                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
21514         }
21515         LDKNodeAnnouncement announcement_message_arg_conv;
21516         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
21517         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
21518         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
21519         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
21520         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21521         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21522         uint64_t ret_ref = (uint64_t)ret_var.inner;
21523         if (ret_var.is_owned) {
21524                 ret_ref |= 1;
21525         }
21526         return ret_ref;
21527 }
21528
21529 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
21530         LDKNodeAnnouncementInfo orig_conv;
21531         orig_conv.inner = (void*)(orig & (~1));
21532         orig_conv.is_owned = false;
21533         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
21534         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21535         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21536         uint64_t ret_ref = (uint64_t)ret_var.inner;
21537         if (ret_var.is_owned) {
21538                 ret_ref |= 1;
21539         }
21540         return ret_ref;
21541 }
21542
21543 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
21544         LDKNodeAnnouncementInfo obj_conv;
21545         obj_conv.inner = (void*)(obj & (~1));
21546         obj_conv.is_owned = false;
21547         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
21548         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21549         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21550         CVec_u8Z_free(ret_var);
21551         return ret_arr;
21552 }
21553
21554 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
21555         LDKu8slice ser_ref;
21556         ser_ref.datalen = *((uint32_t*)ser);
21557         ser_ref.data = (int8_t*)(ser + 4);
21558         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
21559         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
21560         return (uint64_t)ret_conv;
21561 }
21562
21563 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
21564         LDKNodeInfo this_obj_conv;
21565         this_obj_conv.inner = (void*)(this_obj & (~1));
21566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21567         NodeInfo_free(this_obj_conv);
21568 }
21569
21570 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
21571         LDKNodeInfo this_ptr_conv;
21572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21573         this_ptr_conv.is_owned = false;
21574         LDKCVec_u64Z val_constr;
21575         val_constr.datalen = *((uint32_t*)val);
21576         if (val_constr.datalen > 0)
21577                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21578         else
21579                 val_constr.data = NULL;
21580         int64_t* val_vals = (int64_t*)(val + 4);
21581         for (size_t i = 0; i < val_constr.datalen; i++) {
21582                 int64_t val_conv_8 = val_vals[i];
21583                 val_constr.data[i] = val_conv_8;
21584         }
21585         NodeInfo_set_channels(&this_ptr_conv, val_constr);
21586 }
21587
21588 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
21589         LDKNodeInfo this_ptr_conv;
21590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21591         this_ptr_conv.is_owned = false;
21592         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
21593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21595         uint64_t ret_ref = (uint64_t)ret_var.inner;
21596         if (ret_var.is_owned) {
21597                 ret_ref |= 1;
21598         }
21599         return ret_ref;
21600 }
21601
21602 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
21603         LDKNodeInfo this_ptr_conv;
21604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21605         this_ptr_conv.is_owned = false;
21606         LDKRoutingFees val_conv;
21607         val_conv.inner = (void*)(val & (~1));
21608         val_conv.is_owned = (val & 1) || (val == 0);
21609         val_conv = RoutingFees_clone(&val_conv);
21610         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
21611 }
21612
21613 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
21614         LDKNodeInfo this_ptr_conv;
21615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21616         this_ptr_conv.is_owned = false;
21617         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
21618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21620         uint64_t ret_ref = (uint64_t)ret_var.inner;
21621         if (ret_var.is_owned) {
21622                 ret_ref |= 1;
21623         }
21624         return ret_ref;
21625 }
21626
21627 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
21628         LDKNodeInfo this_ptr_conv;
21629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21630         this_ptr_conv.is_owned = false;
21631         LDKNodeAnnouncementInfo val_conv;
21632         val_conv.inner = (void*)(val & (~1));
21633         val_conv.is_owned = (val & 1) || (val == 0);
21634         val_conv = NodeAnnouncementInfo_clone(&val_conv);
21635         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
21636 }
21637
21638 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
21639         LDKCVec_u64Z channels_arg_constr;
21640         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
21641         if (channels_arg_constr.datalen > 0)
21642                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
21643         else
21644                 channels_arg_constr.data = NULL;
21645         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
21646         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
21647                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
21648                 channels_arg_constr.data[i] = channels_arg_conv_8;
21649         }
21650         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
21651         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
21652         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
21653         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
21654         LDKNodeAnnouncementInfo announcement_info_arg_conv;
21655         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
21656         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
21657         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
21658         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
21659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21661         uint64_t ret_ref = (uint64_t)ret_var.inner;
21662         if (ret_var.is_owned) {
21663                 ret_ref |= 1;
21664         }
21665         return ret_ref;
21666 }
21667
21668 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
21669         LDKNodeInfo orig_conv;
21670         orig_conv.inner = (void*)(orig & (~1));
21671         orig_conv.is_owned = false;
21672         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
21673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21675         uint64_t ret_ref = (uint64_t)ret_var.inner;
21676         if (ret_var.is_owned) {
21677                 ret_ref |= 1;
21678         }
21679         return ret_ref;
21680 }
21681
21682 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
21683         LDKNodeInfo obj_conv;
21684         obj_conv.inner = (void*)(obj & (~1));
21685         obj_conv.is_owned = false;
21686         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
21687         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21688         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21689         CVec_u8Z_free(ret_var);
21690         return ret_arr;
21691 }
21692
21693 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
21694         LDKu8slice ser_ref;
21695         ser_ref.datalen = *((uint32_t*)ser);
21696         ser_ref.data = (int8_t*)(ser + 4);
21697         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
21698         *ret_conv = NodeInfo_read(ser_ref);
21699         return (uint64_t)ret_conv;
21700 }
21701
21702 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
21703         LDKNetworkGraph obj_conv;
21704         obj_conv.inner = (void*)(obj & (~1));
21705         obj_conv.is_owned = false;
21706         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
21707         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21708         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21709         CVec_u8Z_free(ret_var);
21710         return ret_arr;
21711 }
21712
21713 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
21714         LDKu8slice ser_ref;
21715         ser_ref.datalen = *((uint32_t*)ser);
21716         ser_ref.data = (int8_t*)(ser + 4);
21717         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
21718         *ret_conv = NetworkGraph_read(ser_ref);
21719         return (uint64_t)ret_conv;
21720 }
21721
21722 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
21723         LDKThirtyTwoBytes genesis_hash_ref;
21724         CHECK(*((uint32_t*)genesis_hash) == 32);
21725         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
21726         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
21727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21729         uint64_t ret_ref = (uint64_t)ret_var.inner;
21730         if (ret_var.is_owned) {
21731                 ret_ref |= 1;
21732         }
21733         return ret_ref;
21734 }
21735
21736 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
21737         LDKNetworkGraph this_arg_conv;
21738         this_arg_conv.inner = (void*)(this_arg & (~1));
21739         this_arg_conv.is_owned = false;
21740         LDKNodeAnnouncement msg_conv;
21741         msg_conv.inner = (void*)(msg & (~1));
21742         msg_conv.is_owned = false;
21743         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21744         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
21745         return (uint64_t)ret_conv;
21746 }
21747
21748 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
21749         LDKNetworkGraph this_arg_conv;
21750         this_arg_conv.inner = (void*)(this_arg & (~1));
21751         this_arg_conv.is_owned = false;
21752         LDKUnsignedNodeAnnouncement msg_conv;
21753         msg_conv.inner = (void*)(msg & (~1));
21754         msg_conv.is_owned = false;
21755         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21756         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
21757         return (uint64_t)ret_conv;
21758 }
21759
21760 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
21761         LDKNetworkGraph this_arg_conv;
21762         this_arg_conv.inner = (void*)(this_arg & (~1));
21763         this_arg_conv.is_owned = false;
21764         LDKChannelAnnouncement msg_conv;
21765         msg_conv.inner = (void*)(msg & (~1));
21766         msg_conv.is_owned = false;
21767         LDKAccess *chain_access_conv_ptr = NULL;
21768         if (chain_access != 0) {
21769                 LDKAccess chain_access_conv;
21770                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21771                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21772                 *chain_access_conv_ptr = chain_access_conv;
21773         }
21774         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21775         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21776         return (uint64_t)ret_conv;
21777 }
21778
21779 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
21780         LDKNetworkGraph this_arg_conv;
21781         this_arg_conv.inner = (void*)(this_arg & (~1));
21782         this_arg_conv.is_owned = false;
21783         LDKUnsignedChannelAnnouncement msg_conv;
21784         msg_conv.inner = (void*)(msg & (~1));
21785         msg_conv.is_owned = false;
21786         LDKAccess *chain_access_conv_ptr = NULL;
21787         if (chain_access != 0) {
21788                 LDKAccess chain_access_conv;
21789                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
21790                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
21791                 *chain_access_conv_ptr = chain_access_conv;
21792         }
21793         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21794         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
21795         return (uint64_t)ret_conv;
21796 }
21797
21798 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
21799         LDKNetworkGraph this_arg_conv;
21800         this_arg_conv.inner = (void*)(this_arg & (~1));
21801         this_arg_conv.is_owned = false;
21802         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
21803 }
21804
21805 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
21806         LDKNetworkGraph this_arg_conv;
21807         this_arg_conv.inner = (void*)(this_arg & (~1));
21808         this_arg_conv.is_owned = false;
21809         LDKChannelUpdate msg_conv;
21810         msg_conv.inner = (void*)(msg & (~1));
21811         msg_conv.is_owned = false;
21812         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21813         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
21814         return (uint64_t)ret_conv;
21815 }
21816
21817 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
21818         LDKNetworkGraph this_arg_conv;
21819         this_arg_conv.inner = (void*)(this_arg & (~1));
21820         this_arg_conv.is_owned = false;
21821         LDKUnsignedChannelUpdate msg_conv;
21822         msg_conv.inner = (void*)(msg & (~1));
21823         msg_conv.is_owned = false;
21824         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
21825         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
21826         return (uint64_t)ret_conv;
21827 }
21828
21829 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
21830         LDKFilesystemPersister this_obj_conv;
21831         this_obj_conv.inner = (void*)(this_obj & (~1));
21832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21833         FilesystemPersister_free(this_obj_conv);
21834 }
21835
21836 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
21837         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
21838         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
21839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21841         uint64_t ret_ref = (uint64_t)ret_var.inner;
21842         if (ret_var.is_owned) {
21843                 ret_ref |= 1;
21844         }
21845         return ret_ref;
21846 }
21847
21848 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
21849         LDKFilesystemPersister this_arg_conv;
21850         this_arg_conv.inner = (void*)(this_arg & (~1));
21851         this_arg_conv.is_owned = false;
21852         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
21853         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21854         return ret_conv;
21855 }
21856
21857 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
21858         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
21859         LDKChannelManager manager_conv;
21860         manager_conv.inner = (void*)(manager & (~1));
21861         manager_conv.is_owned = false;
21862         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21863         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
21864         return (uint64_t)ret_conv;
21865 }
21866
21867 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
21868         LDKFilesystemPersister this_arg_conv;
21869         this_arg_conv.inner = (void*)(this_arg & (~1));
21870         this_arg_conv.is_owned = false;
21871         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
21872         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21873         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
21874         return (uint64_t)ret_conv;
21875 }
21876
21877 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
21878         LDKFilesystemPersister this_arg_conv;
21879         this_arg_conv.inner = (void*)(this_arg & (~1));
21880         this_arg_conv.is_owned = false;
21881         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
21882         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
21883         return (uint64_t)ret;
21884 }
21885
21886 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
21887         LDKBackgroundProcessor this_obj_conv;
21888         this_obj_conv.inner = (void*)(this_obj & (~1));
21889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21890         BackgroundProcessor_free(this_obj_conv);
21891 }
21892
21893 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
21894         if ((this_ptr & 1) != 0) return;
21895         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
21896         FREE((void*)this_ptr);
21897         ChannelManagerPersister_free(this_ptr_conv);
21898 }
21899
21900 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) {
21901         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
21902         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
21903         LDKChainMonitor chain_monitor_conv;
21904         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
21905         chain_monitor_conv.is_owned = false;
21906         LDKChannelManager channel_manager_conv;
21907         channel_manager_conv.inner = (void*)(channel_manager & (~1));
21908         channel_manager_conv.is_owned = false;
21909         LDKPeerManager peer_manager_conv;
21910         peer_manager_conv.inner = (void*)(peer_manager & (~1));
21911         peer_manager_conv.is_owned = false;
21912         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21913         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
21914         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21915         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21916         uint64_t ret_ref = (uint64_t)ret_var.inner;
21917         if (ret_var.is_owned) {
21918                 ret_ref |= 1;
21919         }
21920         return ret_ref;
21921 }
21922
21923 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
21924         LDKBackgroundProcessor this_arg_conv;
21925         this_arg_conv.inner = (void*)(this_arg & (~1));
21926         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
21927         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
21928         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
21929         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
21930         return (uint64_t)ret_conv;
21931 }
21932
21933 void  __attribute__((visibility("default"))) TS_check_platform() {
21934         check_platform();
21935 }
21936
21937 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
21938         LDKInvoice this_obj_conv;
21939         this_obj_conv.inner = (void*)(this_obj & (~1));
21940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21941         Invoice_free(this_obj_conv);
21942 }
21943
21944 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
21945         LDKInvoice a_conv;
21946         a_conv.inner = (void*)(a & (~1));
21947         a_conv.is_owned = false;
21948         LDKInvoice b_conv;
21949         b_conv.inner = (void*)(b & (~1));
21950         b_conv.is_owned = false;
21951         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
21952         return ret_val;
21953 }
21954
21955 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
21956         LDKInvoice orig_conv;
21957         orig_conv.inner = (void*)(orig & (~1));
21958         orig_conv.is_owned = false;
21959         LDKInvoice ret_var = Invoice_clone(&orig_conv);
21960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21962         uint64_t ret_ref = (uint64_t)ret_var.inner;
21963         if (ret_var.is_owned) {
21964                 ret_ref |= 1;
21965         }
21966         return ret_ref;
21967 }
21968
21969 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
21970         LDKSignedRawInvoice this_obj_conv;
21971         this_obj_conv.inner = (void*)(this_obj & (~1));
21972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21973         SignedRawInvoice_free(this_obj_conv);
21974 }
21975
21976 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
21977         LDKSignedRawInvoice a_conv;
21978         a_conv.inner = (void*)(a & (~1));
21979         a_conv.is_owned = false;
21980         LDKSignedRawInvoice b_conv;
21981         b_conv.inner = (void*)(b & (~1));
21982         b_conv.is_owned = false;
21983         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
21984         return ret_val;
21985 }
21986
21987 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
21988         LDKSignedRawInvoice orig_conv;
21989         orig_conv.inner = (void*)(orig & (~1));
21990         orig_conv.is_owned = false;
21991         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
21992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21994         uint64_t ret_ref = (uint64_t)ret_var.inner;
21995         if (ret_var.is_owned) {
21996                 ret_ref |= 1;
21997         }
21998         return ret_ref;
21999 }
22000
22001 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
22002         LDKRawInvoice this_obj_conv;
22003         this_obj_conv.inner = (void*)(this_obj & (~1));
22004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22005         RawInvoice_free(this_obj_conv);
22006 }
22007
22008 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
22009         LDKRawInvoice this_ptr_conv;
22010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22011         this_ptr_conv.is_owned = false;
22012         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
22013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22015         uint64_t ret_ref = (uint64_t)ret_var.inner;
22016         if (ret_var.is_owned) {
22017                 ret_ref |= 1;
22018         }
22019         return ret_ref;
22020 }
22021
22022 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
22023         LDKRawInvoice this_ptr_conv;
22024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22025         this_ptr_conv.is_owned = false;
22026         LDKRawDataPart val_conv;
22027         val_conv.inner = (void*)(val & (~1));
22028         val_conv.is_owned = (val & 1) || (val == 0);
22029         val_conv = RawDataPart_clone(&val_conv);
22030         RawInvoice_set_data(&this_ptr_conv, val_conv);
22031 }
22032
22033 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
22034         LDKRawInvoice a_conv;
22035         a_conv.inner = (void*)(a & (~1));
22036         a_conv.is_owned = false;
22037         LDKRawInvoice b_conv;
22038         b_conv.inner = (void*)(b & (~1));
22039         b_conv.is_owned = false;
22040         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
22041         return ret_val;
22042 }
22043
22044 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
22045         LDKRawInvoice orig_conv;
22046         orig_conv.inner = (void*)(orig & (~1));
22047         orig_conv.is_owned = false;
22048         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
22049         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22050         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22051         uint64_t ret_ref = (uint64_t)ret_var.inner;
22052         if (ret_var.is_owned) {
22053                 ret_ref |= 1;
22054         }
22055         return ret_ref;
22056 }
22057
22058 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
22059         LDKRawDataPart this_obj_conv;
22060         this_obj_conv.inner = (void*)(this_obj & (~1));
22061         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22062         RawDataPart_free(this_obj_conv);
22063 }
22064
22065 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
22066         LDKRawDataPart this_ptr_conv;
22067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22068         this_ptr_conv.is_owned = false;
22069         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
22070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22072         uint64_t ret_ref = (uint64_t)ret_var.inner;
22073         if (ret_var.is_owned) {
22074                 ret_ref |= 1;
22075         }
22076         return ret_ref;
22077 }
22078
22079 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
22080         LDKRawDataPart this_ptr_conv;
22081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22082         this_ptr_conv.is_owned = false;
22083         LDKPositiveTimestamp val_conv;
22084         val_conv.inner = (void*)(val & (~1));
22085         val_conv.is_owned = (val & 1) || (val == 0);
22086         val_conv = PositiveTimestamp_clone(&val_conv);
22087         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
22088 }
22089
22090 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
22091         LDKRawDataPart a_conv;
22092         a_conv.inner = (void*)(a & (~1));
22093         a_conv.is_owned = false;
22094         LDKRawDataPart b_conv;
22095         b_conv.inner = (void*)(b & (~1));
22096         b_conv.is_owned = false;
22097         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
22098         return ret_val;
22099 }
22100
22101 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
22102         LDKRawDataPart orig_conv;
22103         orig_conv.inner = (void*)(orig & (~1));
22104         orig_conv.is_owned = false;
22105         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
22106         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22107         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22108         uint64_t ret_ref = (uint64_t)ret_var.inner;
22109         if (ret_var.is_owned) {
22110                 ret_ref |= 1;
22111         }
22112         return ret_ref;
22113 }
22114
22115 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
22116         LDKPositiveTimestamp this_obj_conv;
22117         this_obj_conv.inner = (void*)(this_obj & (~1));
22118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22119         PositiveTimestamp_free(this_obj_conv);
22120 }
22121
22122 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
22123         LDKPositiveTimestamp a_conv;
22124         a_conv.inner = (void*)(a & (~1));
22125         a_conv.is_owned = false;
22126         LDKPositiveTimestamp b_conv;
22127         b_conv.inner = (void*)(b & (~1));
22128         b_conv.is_owned = false;
22129         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
22130         return ret_val;
22131 }
22132
22133 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
22134         LDKPositiveTimestamp orig_conv;
22135         orig_conv.inner = (void*)(orig & (~1));
22136         orig_conv.is_owned = false;
22137         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
22138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22140         uint64_t ret_ref = (uint64_t)ret_var.inner;
22141         if (ret_var.is_owned) {
22142                 ret_ref |= 1;
22143         }
22144         return ret_ref;
22145 }
22146
22147 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
22148         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
22149         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
22150         return ret_conv;
22151 }
22152
22153 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
22154         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
22155         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
22156         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
22157         return ret_val;
22158 }
22159
22160 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
22161         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
22162         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
22163         return ret_val;
22164 }
22165
22166 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
22167         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
22168         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
22169         return ret_conv;
22170 }
22171
22172 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
22173         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
22174         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
22175         jboolean ret_val = Currency_eq(a_conv, b_conv);
22176         return ret_val;
22177 }
22178
22179 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
22180         LDKSha256 this_obj_conv;
22181         this_obj_conv.inner = (void*)(this_obj & (~1));
22182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22183         Sha256_free(this_obj_conv);
22184 }
22185
22186 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
22187         LDKSha256 a_conv;
22188         a_conv.inner = (void*)(a & (~1));
22189         a_conv.is_owned = false;
22190         LDKSha256 b_conv;
22191         b_conv.inner = (void*)(b & (~1));
22192         b_conv.is_owned = false;
22193         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
22194         return ret_val;
22195 }
22196
22197 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
22198         LDKSha256 orig_conv;
22199         orig_conv.inner = (void*)(orig & (~1));
22200         orig_conv.is_owned = false;
22201         LDKSha256 ret_var = Sha256_clone(&orig_conv);
22202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22204         uint64_t ret_ref = (uint64_t)ret_var.inner;
22205         if (ret_var.is_owned) {
22206                 ret_ref |= 1;
22207         }
22208         return ret_ref;
22209 }
22210
22211 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
22212         LDKDescription this_obj_conv;
22213         this_obj_conv.inner = (void*)(this_obj & (~1));
22214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22215         Description_free(this_obj_conv);
22216 }
22217
22218 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
22219         LDKDescription a_conv;
22220         a_conv.inner = (void*)(a & (~1));
22221         a_conv.is_owned = false;
22222         LDKDescription b_conv;
22223         b_conv.inner = (void*)(b & (~1));
22224         b_conv.is_owned = false;
22225         jboolean ret_val = Description_eq(&a_conv, &b_conv);
22226         return ret_val;
22227 }
22228
22229 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
22230         LDKDescription orig_conv;
22231         orig_conv.inner = (void*)(orig & (~1));
22232         orig_conv.is_owned = false;
22233         LDKDescription ret_var = Description_clone(&orig_conv);
22234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22236         uint64_t ret_ref = (uint64_t)ret_var.inner;
22237         if (ret_var.is_owned) {
22238                 ret_ref |= 1;
22239         }
22240         return ret_ref;
22241 }
22242
22243 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
22244         LDKPayeePubKey this_obj_conv;
22245         this_obj_conv.inner = (void*)(this_obj & (~1));
22246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22247         PayeePubKey_free(this_obj_conv);
22248 }
22249
22250 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
22251         LDKPayeePubKey a_conv;
22252         a_conv.inner = (void*)(a & (~1));
22253         a_conv.is_owned = false;
22254         LDKPayeePubKey b_conv;
22255         b_conv.inner = (void*)(b & (~1));
22256         b_conv.is_owned = false;
22257         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
22258         return ret_val;
22259 }
22260
22261 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
22262         LDKPayeePubKey orig_conv;
22263         orig_conv.inner = (void*)(orig & (~1));
22264         orig_conv.is_owned = false;
22265         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
22266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22268         uint64_t ret_ref = (uint64_t)ret_var.inner;
22269         if (ret_var.is_owned) {
22270                 ret_ref |= 1;
22271         }
22272         return ret_ref;
22273 }
22274
22275 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
22276         LDKExpiryTime this_obj_conv;
22277         this_obj_conv.inner = (void*)(this_obj & (~1));
22278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22279         ExpiryTime_free(this_obj_conv);
22280 }
22281
22282 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
22283         LDKExpiryTime a_conv;
22284         a_conv.inner = (void*)(a & (~1));
22285         a_conv.is_owned = false;
22286         LDKExpiryTime b_conv;
22287         b_conv.inner = (void*)(b & (~1));
22288         b_conv.is_owned = false;
22289         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
22290         return ret_val;
22291 }
22292
22293 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
22294         LDKExpiryTime orig_conv;
22295         orig_conv.inner = (void*)(orig & (~1));
22296         orig_conv.is_owned = false;
22297         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
22298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22300         uint64_t ret_ref = (uint64_t)ret_var.inner;
22301         if (ret_var.is_owned) {
22302                 ret_ref |= 1;
22303         }
22304         return ret_ref;
22305 }
22306
22307 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
22308         LDKMinFinalCltvExpiry this_obj_conv;
22309         this_obj_conv.inner = (void*)(this_obj & (~1));
22310         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22311         MinFinalCltvExpiry_free(this_obj_conv);
22312 }
22313
22314 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
22315         LDKMinFinalCltvExpiry a_conv;
22316         a_conv.inner = (void*)(a & (~1));
22317         a_conv.is_owned = false;
22318         LDKMinFinalCltvExpiry b_conv;
22319         b_conv.inner = (void*)(b & (~1));
22320         b_conv.is_owned = false;
22321         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
22322         return ret_val;
22323 }
22324
22325 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
22326         LDKMinFinalCltvExpiry orig_conv;
22327         orig_conv.inner = (void*)(orig & (~1));
22328         orig_conv.is_owned = false;
22329         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
22330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22332         uint64_t ret_ref = (uint64_t)ret_var.inner;
22333         if (ret_var.is_owned) {
22334                 ret_ref |= 1;
22335         }
22336         return ret_ref;
22337 }
22338
22339 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
22340         if ((this_ptr & 1) != 0) return;
22341         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
22342         FREE((void*)this_ptr);
22343         Fallback_free(this_ptr_conv);
22344 }
22345
22346 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
22347         LDKFallback* orig_conv = (LDKFallback*)orig;
22348         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
22349         *ret_copy = Fallback_clone(orig_conv);
22350         uint64_t ret_ref = (uint64_t)ret_copy;
22351         return ret_ref;
22352 }
22353
22354 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
22355         LDKFallback* a_conv = (LDKFallback*)a;
22356         LDKFallback* b_conv = (LDKFallback*)b;
22357         jboolean ret_val = Fallback_eq(a_conv, b_conv);
22358         return ret_val;
22359 }
22360
22361 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
22362         LDKInvoiceSignature this_obj_conv;
22363         this_obj_conv.inner = (void*)(this_obj & (~1));
22364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22365         InvoiceSignature_free(this_obj_conv);
22366 }
22367
22368 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
22369         LDKInvoiceSignature a_conv;
22370         a_conv.inner = (void*)(a & (~1));
22371         a_conv.is_owned = false;
22372         LDKInvoiceSignature b_conv;
22373         b_conv.inner = (void*)(b & (~1));
22374         b_conv.is_owned = false;
22375         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
22376         return ret_val;
22377 }
22378
22379 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
22380         LDKInvoiceSignature orig_conv;
22381         orig_conv.inner = (void*)(orig & (~1));
22382         orig_conv.is_owned = false;
22383         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
22384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22386         uint64_t ret_ref = (uint64_t)ret_var.inner;
22387         if (ret_var.is_owned) {
22388                 ret_ref |= 1;
22389         }
22390         return ret_ref;
22391 }
22392
22393 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
22394         LDKPrivateRoute this_obj_conv;
22395         this_obj_conv.inner = (void*)(this_obj & (~1));
22396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22397         PrivateRoute_free(this_obj_conv);
22398 }
22399
22400 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
22401         LDKPrivateRoute a_conv;
22402         a_conv.inner = (void*)(a & (~1));
22403         a_conv.is_owned = false;
22404         LDKPrivateRoute b_conv;
22405         b_conv.inner = (void*)(b & (~1));
22406         b_conv.is_owned = false;
22407         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
22408         return ret_val;
22409 }
22410
22411 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
22412         LDKPrivateRoute orig_conv;
22413         orig_conv.inner = (void*)(orig & (~1));
22414         orig_conv.is_owned = false;
22415         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
22416         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22417         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22418         uint64_t ret_ref = (uint64_t)ret_var.inner;
22419         if (ret_var.is_owned) {
22420                 ret_ref |= 1;
22421         }
22422         return ret_ref;
22423 }
22424
22425 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
22426         LDKSignedRawInvoice this_arg_conv;
22427         this_arg_conv.inner = (void*)(this_arg & (~1));
22428         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22429         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
22430         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
22431         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
22432         return (uint64_t)ret_ref;
22433 }
22434
22435 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
22436         LDKSignedRawInvoice this_arg_conv;
22437         this_arg_conv.inner = (void*)(this_arg & (~1));
22438         this_arg_conv.is_owned = false;
22439         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
22440         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22441         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22442         uint64_t ret_ref = (uint64_t)ret_var.inner;
22443         if (ret_var.is_owned) {
22444                 ret_ref |= 1;
22445         }
22446         return ret_ref;
22447 }
22448
22449 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
22450         LDKSignedRawInvoice this_arg_conv;
22451         this_arg_conv.inner = (void*)(this_arg & (~1));
22452         this_arg_conv.is_owned = false;
22453         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22454         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
22455         return ret_arr;
22456 }
22457
22458 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
22459         LDKSignedRawInvoice this_arg_conv;
22460         this_arg_conv.inner = (void*)(this_arg & (~1));
22461         this_arg_conv.is_owned = false;
22462         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
22463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22465         uint64_t ret_ref = (uint64_t)ret_var.inner;
22466         if (ret_var.is_owned) {
22467                 ret_ref |= 1;
22468         }
22469         return ret_ref;
22470 }
22471
22472 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
22473         LDKSignedRawInvoice this_arg_conv;
22474         this_arg_conv.inner = (void*)(this_arg & (~1));
22475         this_arg_conv.is_owned = false;
22476         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
22477         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
22478         return (uint64_t)ret_conv;
22479 }
22480
22481 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
22482         LDKSignedRawInvoice this_arg_conv;
22483         this_arg_conv.inner = (void*)(this_arg & (~1));
22484         this_arg_conv.is_owned = false;
22485         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
22486         return ret_val;
22487 }
22488
22489 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
22490         LDKRawInvoice this_arg_conv;
22491         this_arg_conv.inner = (void*)(this_arg & (~1));
22492         this_arg_conv.is_owned = false;
22493         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22494         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
22495         return ret_arr;
22496 }
22497
22498 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
22499         LDKRawInvoice this_arg_conv;
22500         this_arg_conv.inner = (void*)(this_arg & (~1));
22501         this_arg_conv.is_owned = false;
22502         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
22503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22505         uint64_t ret_ref = (uint64_t)ret_var.inner;
22506         if (ret_var.is_owned) {
22507                 ret_ref |= 1;
22508         }
22509         return ret_ref;
22510 }
22511
22512 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
22513         LDKRawInvoice this_arg_conv;
22514         this_arg_conv.inner = (void*)(this_arg & (~1));
22515         this_arg_conv.is_owned = false;
22516         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
22517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22519         uint64_t ret_ref = (uint64_t)ret_var.inner;
22520         if (ret_var.is_owned) {
22521                 ret_ref |= 1;
22522         }
22523         return ret_ref;
22524 }
22525
22526 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
22527         LDKRawInvoice this_arg_conv;
22528         this_arg_conv.inner = (void*)(this_arg & (~1));
22529         this_arg_conv.is_owned = false;
22530         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
22531         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22532         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22533         uint64_t ret_ref = (uint64_t)ret_var.inner;
22534         if (ret_var.is_owned) {
22535                 ret_ref |= 1;
22536         }
22537         return ret_ref;
22538 }
22539
22540 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
22541         LDKRawInvoice this_arg_conv;
22542         this_arg_conv.inner = (void*)(this_arg & (~1));
22543         this_arg_conv.is_owned = false;
22544         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
22545         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22546         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22547         uint64_t ret_ref = (uint64_t)ret_var.inner;
22548         if (ret_var.is_owned) {
22549                 ret_ref |= 1;
22550         }
22551         return ret_ref;
22552 }
22553
22554 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
22555         LDKRawInvoice this_arg_conv;
22556         this_arg_conv.inner = (void*)(this_arg & (~1));
22557         this_arg_conv.is_owned = false;
22558         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
22559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22561         uint64_t ret_ref = (uint64_t)ret_var.inner;
22562         if (ret_var.is_owned) {
22563                 ret_ref |= 1;
22564         }
22565         return ret_ref;
22566 }
22567
22568 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
22569         LDKRawInvoice this_arg_conv;
22570         this_arg_conv.inner = (void*)(this_arg & (~1));
22571         this_arg_conv.is_owned = false;
22572         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
22573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22575         uint64_t ret_ref = (uint64_t)ret_var.inner;
22576         if (ret_var.is_owned) {
22577                 ret_ref |= 1;
22578         }
22579         return ret_ref;
22580 }
22581
22582 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
22583         LDKRawInvoice this_arg_conv;
22584         this_arg_conv.inner = (void*)(this_arg & (~1));
22585         this_arg_conv.is_owned = false;
22586         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22587         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
22588         return ret_arr;
22589 }
22590
22591 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
22592         LDKRawInvoice this_arg_conv;
22593         this_arg_conv.inner = (void*)(this_arg & (~1));
22594         this_arg_conv.is_owned = false;
22595         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
22596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22598         uint64_t ret_ref = (uint64_t)ret_var.inner;
22599         if (ret_var.is_owned) {
22600                 ret_ref |= 1;
22601         }
22602         return ret_ref;
22603 }
22604
22605 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
22606         LDKRawInvoice this_arg_conv;
22607         this_arg_conv.inner = (void*)(this_arg & (~1));
22608         this_arg_conv.is_owned = false;
22609         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
22610         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22611         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22612         for (size_t o = 0; o < ret_var.datalen; o++) {
22613                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22614                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22615                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22616                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22617                 if (ret_conv_14_var.is_owned) {
22618                         ret_conv_14_ref |= 1;
22619                 }
22620                 ret_arr_ptr[o] = ret_conv_14_ref;
22621         }
22622         FREE(ret_var.data);
22623         return ret_arr;
22624 }
22625
22626 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
22627         LDKRawInvoice this_arg_conv;
22628         this_arg_conv.inner = (void*)(this_arg & (~1));
22629         this_arg_conv.is_owned = false;
22630         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22631         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
22632         uint64_t ret_ref = (uint64_t)ret_copy;
22633         return ret_ref;
22634 }
22635
22636 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
22637         LDKRawInvoice this_arg_conv;
22638         this_arg_conv.inner = (void*)(this_arg & (~1));
22639         this_arg_conv.is_owned = false;
22640         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
22641         return ret_conv;
22642 }
22643
22644 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
22645         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22646         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
22647         return (uint64_t)ret_conv;
22648 }
22649
22650 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
22651         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
22652         *ret_conv = PositiveTimestamp_from_system_time(time);
22653         return (uint64_t)ret_conv;
22654 }
22655
22656 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
22657         LDKPositiveTimestamp this_arg_conv;
22658         this_arg_conv.inner = (void*)(this_arg & (~1));
22659         this_arg_conv.is_owned = false;
22660         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
22661         return ret_val;
22662 }
22663
22664 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
22665         LDKPositiveTimestamp this_arg_conv;
22666         this_arg_conv.inner = (void*)(this_arg & (~1));
22667         this_arg_conv.is_owned = false;
22668         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
22669         return ret_val;
22670 }
22671
22672 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
22673         LDKInvoice this_arg_conv;
22674         this_arg_conv.inner = (void*)(this_arg & (~1));
22675         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22676         this_arg_conv = Invoice_clone(&this_arg_conv);
22677         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
22678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22680         uint64_t ret_ref = (uint64_t)ret_var.inner;
22681         if (ret_var.is_owned) {
22682                 ret_ref |= 1;
22683         }
22684         return ret_ref;
22685 }
22686
22687 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
22688         LDKInvoice this_arg_conv;
22689         this_arg_conv.inner = (void*)(this_arg & (~1));
22690         this_arg_conv.is_owned = false;
22691         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
22692         *ret_conv = Invoice_check_signature(&this_arg_conv);
22693         return (uint64_t)ret_conv;
22694 }
22695
22696 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
22697         LDKSignedRawInvoice signed_invoice_conv;
22698         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
22699         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
22700         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
22701         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
22702         *ret_conv = Invoice_from_signed(signed_invoice_conv);
22703         return (uint64_t)ret_conv;
22704 }
22705
22706 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
22707         LDKInvoice this_arg_conv;
22708         this_arg_conv.inner = (void*)(this_arg & (~1));
22709         this_arg_conv.is_owned = false;
22710         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
22711         return ret_val;
22712 }
22713
22714 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
22715         LDKInvoice this_arg_conv;
22716         this_arg_conv.inner = (void*)(this_arg & (~1));
22717         this_arg_conv.is_owned = false;
22718         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22719         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
22720         return ret_arr;
22721 }
22722
22723 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
22724         LDKInvoice this_arg_conv;
22725         this_arg_conv.inner = (void*)(this_arg & (~1));
22726         this_arg_conv.is_owned = false;
22727         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22728         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
22729         return ret_arr;
22730 }
22731
22732 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
22733         LDKInvoice this_arg_conv;
22734         this_arg_conv.inner = (void*)(this_arg & (~1));
22735         this_arg_conv.is_owned = false;
22736         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22737         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
22738         return ret_arr;
22739 }
22740
22741 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
22742         LDKInvoice this_arg_conv;
22743         this_arg_conv.inner = (void*)(this_arg & (~1));
22744         this_arg_conv.is_owned = false;
22745         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
22746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22748         uint64_t ret_ref = (uint64_t)ret_var.inner;
22749         if (ret_var.is_owned) {
22750                 ret_ref |= 1;
22751         }
22752         return ret_ref;
22753 }
22754
22755 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
22756         LDKInvoice this_arg_conv;
22757         this_arg_conv.inner = (void*)(this_arg & (~1));
22758         this_arg_conv.is_owned = false;
22759         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22760         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
22761         return ret_arr;
22762 }
22763
22764 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
22765         LDKInvoice this_arg_conv;
22766         this_arg_conv.inner = (void*)(this_arg & (~1));
22767         this_arg_conv.is_owned = false;
22768         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
22769         return ret_val;
22770 }
22771
22772 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
22773         LDKInvoice this_arg_conv;
22774         this_arg_conv.inner = (void*)(this_arg & (~1));
22775         this_arg_conv.is_owned = false;
22776         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
22777         return ret_val;
22778 }
22779
22780 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
22781         LDKInvoice this_arg_conv;
22782         this_arg_conv.inner = (void*)(this_arg & (~1));
22783         this_arg_conv.is_owned = false;
22784         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
22785         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22786         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22787         for (size_t o = 0; o < ret_var.datalen; o++) {
22788                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
22789                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22790                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22791                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
22792                 if (ret_conv_14_var.is_owned) {
22793                         ret_conv_14_ref |= 1;
22794                 }
22795                 ret_arr_ptr[o] = ret_conv_14_ref;
22796         }
22797         FREE(ret_var.data);
22798         return ret_arr;
22799 }
22800
22801 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
22802         LDKInvoice this_arg_conv;
22803         this_arg_conv.inner = (void*)(this_arg & (~1));
22804         this_arg_conv.is_owned = false;
22805         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
22806         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
22807         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
22808         for (size_t l = 0; l < ret_var.datalen; l++) {
22809                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
22810                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22811                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22812                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
22813                 if (ret_conv_11_var.is_owned) {
22814                         ret_conv_11_ref |= 1;
22815                 }
22816                 ret_arr_ptr[l] = ret_conv_11_ref;
22817         }
22818         FREE(ret_var.data);
22819         return ret_arr;
22820 }
22821
22822 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
22823         LDKInvoice this_arg_conv;
22824         this_arg_conv.inner = (void*)(this_arg & (~1));
22825         this_arg_conv.is_owned = false;
22826         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
22827         return ret_conv;
22828 }
22829
22830 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
22831         LDKInvoice this_arg_conv;
22832         this_arg_conv.inner = (void*)(this_arg & (~1));
22833         this_arg_conv.is_owned = false;
22834         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
22835         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
22836         uint64_t ret_ref = (uint64_t)ret_copy;
22837         return ret_ref;
22838 }
22839
22840 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
22841         LDKStr description_conv = str_ref_to_owned_c(description);
22842         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
22843         *ret_conv = Description_new(description_conv);
22844         return (uint64_t)ret_conv;
22845 }
22846
22847 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
22848         LDKDescription this_arg_conv;
22849         this_arg_conv.inner = (void*)(this_arg & (~1));
22850         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22851         this_arg_conv = Description_clone(&this_arg_conv);
22852         LDKStr ret_str = Description_into_inner(this_arg_conv);
22853         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22854         return ret_conv;
22855 }
22856
22857 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
22858         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
22859         *ret_conv = ExpiryTime_from_seconds(seconds);
22860         return (uint64_t)ret_conv;
22861 }
22862
22863 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
22864         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
22865         *ret_conv = ExpiryTime_from_duration(duration);
22866         return (uint64_t)ret_conv;
22867 }
22868
22869 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
22870         LDKExpiryTime this_arg_conv;
22871         this_arg_conv.inner = (void*)(this_arg & (~1));
22872         this_arg_conv.is_owned = false;
22873         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
22874         return ret_val;
22875 }
22876
22877 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
22878         LDKExpiryTime this_arg_conv;
22879         this_arg_conv.inner = (void*)(this_arg & (~1));
22880         this_arg_conv.is_owned = false;
22881         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
22882         return ret_val;
22883 }
22884
22885 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
22886         LDKRouteHint hops_conv;
22887         hops_conv.inner = (void*)(hops & (~1));
22888         hops_conv.is_owned = (hops & 1) || (hops == 0);
22889         hops_conv = RouteHint_clone(&hops_conv);
22890         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
22891         *ret_conv = PrivateRoute_new(hops_conv);
22892         return (uint64_t)ret_conv;
22893 }
22894
22895 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
22896         LDKPrivateRoute this_arg_conv;
22897         this_arg_conv.inner = (void*)(this_arg & (~1));
22898         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
22899         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
22900         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
22901         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22902         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22903         uint64_t ret_ref = (uint64_t)ret_var.inner;
22904         if (ret_var.is_owned) {
22905                 ret_ref |= 1;
22906         }
22907         return ret_ref;
22908 }
22909
22910 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
22911         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
22912         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
22913         return ret_conv;
22914 }
22915
22916 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
22917         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
22918         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
22919         jboolean ret_val = CreationError_eq(a_conv, b_conv);
22920         return ret_val;
22921 }
22922
22923 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
22924         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
22925         LDKStr ret_str = CreationError_to_str(o_conv);
22926         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22927         return ret_conv;
22928 }
22929
22930 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
22931         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
22932         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
22933         return ret_conv;
22934 }
22935
22936 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
22937         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
22938         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
22939         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
22940         return ret_val;
22941 }
22942
22943 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
22944         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
22945         LDKStr ret_str = SemanticError_to_str(o_conv);
22946         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22947         return ret_conv;
22948 }
22949
22950 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
22951         if ((this_ptr & 1) != 0) return;
22952         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
22953         FREE((void*)this_ptr);
22954         SignOrCreationError_free(this_ptr_conv);
22955 }
22956
22957 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
22958         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
22959         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
22960         *ret_copy = SignOrCreationError_clone(orig_conv);
22961         uint64_t ret_ref = (uint64_t)ret_copy;
22962         return ret_ref;
22963 }
22964
22965 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
22966         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
22967         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
22968         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
22969         return ret_val;
22970 }
22971
22972 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
22973         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
22974         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
22975         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22976         return ret_conv;
22977 }
22978
22979 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) {
22980         LDKChannelManager channelmanager_conv;
22981         channelmanager_conv.inner = (void*)(channelmanager & (~1));
22982         channelmanager_conv.is_owned = false;
22983         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
22984         LDKCurrency network_conv = LDKCurrency_from_js(network);
22985         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
22986         LDKStr description_conv = str_ref_to_owned_c(description);
22987         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22988         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
22989         return (uint64_t)ret_conv;
22990 }
22991
22992 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
22993         LDKStr s_conv = str_ref_to_owned_c(s);
22994         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
22995         *ret_conv = SiPrefix_from_str(s_conv);
22996         return (uint64_t)ret_conv;
22997 }
22998
22999 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
23000         LDKStr s_conv = str_ref_to_owned_c(s);
23001         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
23002         *ret_conv = Invoice_from_str(s_conv);
23003         return (uint64_t)ret_conv;
23004 }
23005
23006 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
23007         LDKStr s_conv = str_ref_to_owned_c(s);
23008         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
23009         *ret_conv = SignedRawInvoice_from_str(s_conv);
23010         return (uint64_t)ret_conv;
23011 }
23012
23013 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
23014         LDKInvoice o_conv;
23015         o_conv.inner = (void*)(o & (~1));
23016         o_conv.is_owned = false;
23017         LDKStr ret_str = Invoice_to_str(&o_conv);
23018         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23019         return ret_conv;
23020 }
23021
23022 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
23023         LDKSignedRawInvoice o_conv;
23024         o_conv.inner = (void*)(o & (~1));
23025         o_conv.is_owned = false;
23026         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
23027         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23028         return ret_conv;
23029 }
23030
23031 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
23032         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
23033         LDKStr ret_str = Currency_to_str(o_conv);
23034         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23035         return ret_conv;
23036 }
23037
23038 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
23039         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
23040         LDKStr ret_str = SiPrefix_to_str(o_conv);
23041         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
23042         return ret_conv;
23043 }
23044